# Zero-Downtime Deployments for Docker Container Sites in xCloud

> Deploy Git container sites without downtime: Release mode works for Dockerfile builds, app recipes and docker-compose files with one web service, a database and same-code workers.

A normal container deploy stops the running container, builds the new image and starts it again, so visitors get errors until the new container answers. With **Release mode** in **[xCloud](/)**, the new container starts next to the live one and gets traffic only after it passes a health check.

This guide covers what is specific to container sites, including sites that run their repository's own docker-compose file. Read [How to use zero-downtime deployments](/docs/zero-downtime-deploys-with-release-mode-in-xcloud/) for the basics. For server sizes and prices, see [Docker container hosting](/docker-hosting/). For every stack that can deploy without downtime, see [zero-downtime deployments in xCloud](/zero-downtime-deployments/).

## Requirements

- A site deployed from Git as a **Docker container** on a Docker server, built from one of these:
  - the repository's own **Dockerfile** (the **Dockerfile** option under **Deploy with**),
  - an **app recipe**, which xCloud uses for apps such as Flask, Django or Rails that have no Dockerfile, or
  - the repository's own **docker-compose file** (see the next section for what it may contain).
- The site publishes **one** website port.
- xCloud's default deploy script. Release mode builds and starts the container itself.
- The **Manage deploy scripts** permission to turn Release mode on.

Every team can use Release mode. Each site opts in on its own.

## What a docker-compose site needs

Release mode switches one service, the one that serves your website. The rest of your compose file keeps running beside it. Your compose file works with Release mode when:

- **One web service** publishes the site's port, and only that one port.
- The web service is **built from your repository** (a `build:` section), not a ready-made `image:`.
- **Supporting services**, such as PostgreSQL, Redis or a mail catcher, publish no ports. They keep running and keep their data during deploys and rollbacks.
- **Workers** (for example a queue worker) use the same `build:` settings as the web service and their own `command:`. They restart from each new release, so they always run the code you just deployed.
- **No service may depend on the web service** (`depends_on`). The web container changes with each release.
- The web service **keeps no writable data**: it uses no bind mounts, and any named volume it uses must be read-only.
- Workers use **no bind mounts**. Supporting services may bind-mount files, but only from **inside the site's folder**.
- The compose file uses only `services`, `networks` and `volumes` at the top level, with bridge networking.
- The compose file has **no `include` or `extends`**, keeps every env file inside the site's folder and mounts no Docker socket. No service uses host or none networking. The web service has no fixed network address.

This list covers the main rules, not every one. If your compose file uses another setting Release mode can't use, the card names it.

xCloud sets the site's own Compose project name for you. If your compose file sets a different `name:`, the card tells you which name to use.

## How a container deploy works

1. xCloud pulls the commit and builds a new image for the release.
2. It starts the web container from that image on a second port, next to the live container.
3. It checks the new container on `127.0.0.1` until it answers with a status below 500. The log shows, for example, "Container health check passed on 127.0.0.1:8100 (HTTP 200)." An app recipe uses its own health check path.
4. nginx reloads gracefully and sends new requests to the new container.
5. The old container gets time to finish its requests, then it stops. Its image stays on the server for rollback. On a docker-compose site, workers built from the same code restart from the new image; the database and other supporting services keep running.

If the image build or the health check fails, nothing switches and the old container keeps serving. The deploy log ends with "The live release is unchanged."

## Step 1: Turn Release mode on

Open the site and click **Git**. Scroll to the **Release mode (zero-downtime deploys)** card and click the switch.

![Click the switch on the 'Release mode (zero-downtime deploys)' card in Site → Git](/_landing/docs/zero-downtime-deploys-for-docker-container-sites-image-5.png)

Confirm with **Turn on**. The site stays online. The running container becomes the first release, marked **Converted**.

If your compose file has a setting Release mode can't use, the card shows one message instead. It names the service and tells you what to change. See [Messages you may see](#messages-you-may-see).

The card has no **Shared between releases** section on container sites. Each release's container reads the site's `.env` from the site folder, so your environment values stay the same across releases. See [Environment variables and Git deployments](/docs/environment-variables-and-git-deployments-in-xcloud/).

## Step 2: Deploy and check the releases

Deploy as usual, for example with **Deploy Now**. Each deploy adds a release, and the newest healthy one is **Live**.

![The releases list of a docker-compose site after a deploy, with the new release Live](/_landing/docs/zero-downtime-deploys-for-docker-container-sites-image-7.png)

xCloud keeps the last 3 release images. After a new release goes live, the oldest image is removed, and that release loses its **Rollback** button.

## Step 3: Roll back if you need to

Click **Rollback** on a kept release and confirm with **Rollback**. xCloud starts its image on the idle port, checks it, then switches nginx, so a container rollback can take up to a minute. The release you rolled back to shows **Rolled back** and **Live**. Your database and `.env` are not changed.

![Click Rollback on a kept release; the rolled-back release is now Live](/_landing/docs/zero-downtime-deploys-for-docker-container-sites-image-8.png)

More in [How to roll back a deployment](/docs/roll-back-a-deployment-in-xcloud/).

## Backups and restores

Backups and restores of a docker-compose site work as before, with Release mode on or off. They still stop the site briefly while its data is saved or restored. A supporting service that had already stopped, such as a one-off job that finished, stays stopped after a backup or restore. See [Back up and restore Docker apps](/docs/backup-and-restore-docker-apps/).

## Turn Release mode off

Click the switch and confirm **Turn off**. The live image runs as the site's own container again, and the other release images are removed.

You can't change the site's domain while Release mode is on. Turn it off first.

To add or remove a worker, or to change the compose project, web service, networks or volumes, turn Release mode off first. Deploy the changed compose file, then turn Release mode on again.

## Messages you may see

- **More than one public port:** "Zero-downtime deploys only work for sites with one public port. This site has 2." (with your number).
- **No single web service:** "Exactly one web service must publish the site port. Set the site port on one web service before turning on release mode." Publish the site's port on the website service only.
- **A web service from a ready-made image:** "The web service must build from the repository. Image-only web services are not supported yet. Add repository build settings before turning on release mode." Give the web service a `build:` section that points at your repository.
- **A supporting service with a port:** "Supporting service … publishes a port. Release mode supports one public web service; remove the other published ports before trying again." Remove `ports:` from that service. Services reach each other on the Compose network without published ports.
- **A worker built from different code:** "Supporting service … builds different code. Use the web service's build settings for a same-code worker before trying again." Give the worker the same `build:` settings as the web service.
- **A folder outside the site:** "Service … uses volumes.source outside this site. Move the bind mount inside this site before trying again." Change that service's bind mount so its source folder is inside the site's folder.
- **A worker added or removed while Release mode is on:** "The same-code workers changed. Turn release mode off before adding or removing workers, then try again." Turn Release mode off, deploy the changed compose file, then turn it on again.
- **A service that depends on the web service:** "Service … depends on web service …. Remove this dependency before turning on release mode; the web container changes with each release." Remove the web service from that service's `depends_on:`.
- **A web service with writable volumes:** "The web service has writable data volumes. Safe switching for these volumes is not supported yet. Keep release mode off for this site until safe switching is supported." Make every named volume of the web service read-only, or keep Release mode off for this site.
- **A web service with a writable bind mount:** "The web service has writable bind-mounted data. Safe switching for these mounts is not supported yet." Remove the bind mount from the web service. Use a read-only named volume if it needs files.
- **A web service that mounts the site's folder:** "The web service mounts repository code. Code bind mounts are not supported yet. Remove code bind mounts before turning on release mode." Remove bind mounts from the site's folder on the web service. The release image already has your code.
- **A worker with a bind mount:** "Worker … mounts repository code. Remove code bind mounts before turning on release mode." Remove every bind mount from that worker. Workers already have your code from the release.
- **A worker that runs the website command:** "Service … runs the website command. Give same-code workers their own command before trying again." Give the worker its own `command:` (for example, the queue worker command).
- **A changed stack while Release mode is on:** "The compose project, web service, networks or volumes changed. Turn release mode off before changing the supporting stack." Turn Release mode off, deploy, then turn it on again.
- **A second website port on a docker-compose site:** "Release mode for compose files currently supports one website port. Remove the additional port mappings first." Open the site and click **Domain**. Under **Additional Domains**, click **Edit**, click **Remove** next to each domain whose **Port** is not the site's own port, click **Save**, then try again.
- **A different Compose project name:** "Release mode needs this site's own Compose project. Set name: and COMPOSE_PROJECT_NAME to … before trying again." In your docker-compose file, set `name:` to the name in the message. Then open the site's **Environment** page, set `COMPOSE_PROJECT_NAME` to the same name, click **Update Environment**, and try again.
- **A custom deploy script:** "This site has a custom deploy script. Release mode builds and starts the container itself, so reset the deploy script to the default, then try again."
- **Shared paths:** "Container sites cannot share folders between releases. Each release's container reads the site's .env file from its own folder."
- **Turning it on while you create the site:** "Zero-downtime deploys cannot be turned on while creating a Docker site. For sites built from a Dockerfile, turn it on afterwards under Git settings." Create the site first, then turn Release mode on from **Git** as in Step 1.

More messages and fixes are in [Release mode messages and fixes](/docs/release-mode-messages-and-fixes/). For setting up the site itself, see [Deploy a custom Docker application from a Git repository](/docs/how-to-deploy-custom-docker-application-from-git-repository/).

## Frequently asked questions

### Which container sites can use Release mode?

Git sites on a Docker server built from the repository's own Dockerfile, from an app recipe (for apps such as Flask, Django or Rails), or from the repository's own docker-compose file. A compose site needs one web service built from the repository; supporting services such as PostgreSQL and workers built from the same code are fine. Every site needs one website port and xCloud's default deploy script.

### Do my database and workers restart when I deploy a docker-compose site?

Your database and other supporting services keep running. Workers built from the same code as the website restart from the new release, so they always run the code you just deployed.

### How many releases can I roll back to on a container site?

Three. xCloud keeps the last 3 release images and removes the oldest one after a new release goes live.

### Can I share folders between releases on a container site?

No. Container sites cannot share folders between releases: each release's container reads the site's .env file from its own folder. The card shows no shared files section for container sites.

## Related guides

- [How to use zero-downtime deployments (Release mode)](/docs/zero-downtime-deploys-with-release-mode-in-xcloud/)
- [Release mode messages and fixes](/docs/release-mode-messages-and-fixes/)
- [Back up and restore Docker apps](/docs/backup-and-restore-docker-apps/)
- [Get alerts when a Docker site's container stops](/docs/docker-container-down-alerts-in-xcloud/)
- [Manage Release mode with the Public API and MCP](/docs/manage-release-mode-with-public-api-and-mcp/)

If you run into any issues with zero-downtime deployments for your container site, feel free to reach out to our [support team](/docs/access-built-in-support-portal-in-xcloud/).
