Containers are in beta. Contact support to enable them for your server.
Services let you run extra containers next to your application, such as Postgres, Redis or a background worker. Each one runs from its own image on the site’s private network, and your application reaches it by its service name. This can be found in the Services card on the site’s Containers tab.

How services work

Every container site has a primary service called web. It’s the only service that receives web traffic from your domain. You can add up to nine more. When a site has more than one service, they all join a private network for that site. Each service can reach the others by name, e.g. db:5432 or cache:6379. Other sites can’t reach them. Services other than web can’t be reached from your domain, from the internet or from the server itself. Like the primary service, services restart automatically if they exit and start again after a server reboot.
Adding a second service to a site, or removing the last extra service, restarts web so it can join or leave the private network.
You don’t need a MySQL serviceContainer sites can use the server’s own MySQL. See Connecting to MySQL. Add a service for software the server doesn’t provide.

Adding a service

Click Add service and fill in: Click Add service. The image is pulled and the service started in the background. You can also add services when you create the site, either in the Services card of the Create Site wizard or by importing a Compose file. Services added in the wizard only take a name, image and port. Add environment variables and volumes once the site is created.

Data volumes

If you add a well-known data store, Cito suggests a volume for its data directory, and adds one automatically when you add it from the wizard. Without a volume, the data lives inside the container and is lost when the container is recreated. The suggested volume is data/<service name>, e.g. data/db, in your site’s home directory. Click Add volume for… to add it. For any other image that stores data, add a volume yourself.

Start order

Depends on controls the order services start in. If web depends on db, then db is started before web.
Cito doesn’t wait for a service to be ready before starting the next one. For example, web may start before Postgres accepts connections, so your application should retry its connections on startup. Dependencies must exist and can’t form a cycle. To remove a service that another service depends on, remove it from that service’s Depends on first.

Managing a service

Each row in the Services card shows the service’s image, status and any errors, with buttons to: A stopped service stays stopped, including after a server reboot, until you start it. The primary web service is edited from the Configuration card, and can’t be removed. To remove it, delete the site.

Editing a service

Click Edit, change what you need and click Save & Recreate. Like the primary service, the image is pulled and the service’s container is replaced in the background. Files in volumes are kept, and the rest of the site keeps running.

Removing a service

Click Remove and confirm. The service’s container is stopped and removed, and its image is deleted if nothing else uses it. Volume folders are not deleted. The data stays in your site’s home directory until you delete it yourself.

Example: Laravel with Redis

A Laravel application that uses the server’s MySQL and a Redis service for its cache and queues:
  • web: your application image, listening on port 8080, depending on redis.
  • redis: redis:7 on port 6379, with a volume data/redis mounted at /data.
  • worker: your application image again, with the command override php artisan queue:work, depending on redis. A worker doesn’t listen on a port, but the field is required, so enter the same port as web.
Then set the following on web and worker: