Zero-downtime deploys on a single server with Docker Compose

How we deploy Mesito and Forkly with no failed requests and no Kubernetes: start the new container off the network, wait until healthy, then swap.

The short answer

We start a second copy of the service, keep it off the networks the proxy uses until its own health check passes, then attach it under the same name and stop the old one. The proxy retries for a short time if a request lands mid-switch. On Mesito, 855 probe requests during a deploy and a rollback got 0 errors, and the slowest took 1.2 seconds.

On this page
  1. Why does a plain docker compose up -d drop requests?
  2. How does our rollout work?
  3. Why does the proxy also need retries?
  4. What did we measure?
  5. What does this not cover?
  6. Should you do this or move to Kubernetes?

Mesito (our real-estate CRM) and Forkly (our restaurant ordering platform) each run as a few Docker Compose services behind one reverse proxy on one server. Until November 2026, a deploy meant docker compose up -d: Compose stopped the old container and started the new one, and for a few seconds the site answered with errors.

We wanted deploys with no failed requests, without moving to Kubernetes or a second server. This post covers the method, what we measured, and the two problems we hit on the way.

Why does a plain docker compose up -d drop requests?

Compose replaces a container by stopping the old one first, then starting the new one. Between the two, nothing serves the app. Even when the new container starts quickly, the app inside it needs time to boot, connect to the database and pass its health check. Requests in that gap fail.

How does our rollout work?

For each HTTP service (the web front end and the API), the deploy script:

  1. Starts a second container of the service with the new image. Compose can run two containers of one service if the service has no fixed container_name and no published port.
  2. Keeps the new container off the serving networks while it boots: the network the proxy uses, and the network the web front end uses to reach the API. Nothing can send it traffic yet.
  3. Waits for the new container’s own health check, by container id, not by service name. Every service needs a real health check for this; ours call a ready endpoint that also checks the database.
  4. Attaches the new container to the serving networks under the old container’s aliases, so the proxy and the front end find it under the same name.
  5. Stops the old container, giving it its normal grace period to finish requests it already has, then removes it.

If the new container never gets healthy, it’s removed and the old one is never stopped. A broken release leaves the old version serving.

A service whose image didn’t change is left alone. Background workers aren’t rolled this way; they’re recreated in place, because nothing waits on them over HTTP.

Why does the proxy also need retries?

There is a short window where the proxy can pick a container that is about to stop. We use Caddy, and its load-balancing settings can retry an upstream for a short time instead of returning an error straight away. With the retries, a request that lands at the wrong moment waits a fraction of a second longer instead of failing.

We learned this on a third app. Its rollout ran before its proxy block had the retry setting, and one probe request out of 282 got a 503 during the switch. With the retry added, that window closed.

What did we measure?

A rollout that “seems fine” isn’t proof, so we ran a probe during real deploys: a request every 0.3 seconds through the proxy, hitting a page, an API write and the ready endpoint.

App Deploys measured Result
A throwaway test app 5 runs 0 errors; slowest 0.06 s, except one 2.0 s wait whose cause we didn’t find
Mesito a deploy and a rollback 0 errors in 855 probes; slowest 1.2 s (normal: median 0.18 s)
Forkly a deploy every page and API write answered across 200 probe rounds; slowest 1.9 s

The Forkly run had one surprise: some 429 Too Many Requests answers from the ready endpoint, in bursts about every 60 seconds. They weren’t at the switch times. Our own probe was hitting the API’s per-address rate limit. It’s a reminder to read a non-2xx answer before calling it a deploy error.

Forkly also needed one change before it could roll: the web front end reached the API over the same network the proxy used. We gave the two services their own internal network, so the API could be kept away from the front end while it booted.

What does this not cover?

  • Database migrations run before the rollout. For the old and new versions to work against the same schema during the switch, every migration has to be backward compatible: add first, switch reads later, drop in a later release.
  • Long-lived connections, such as WebSockets, are closed when the old container stops. Clients have to reconnect.
  • The server itself is still one machine. This removes downtime from deploys, not from hardware failure.

Should you do this or move to Kubernetes?

For a few services on one or two servers, a rollout script of this kind and a proxy with retries gave us deploys with no measured failed requests. The requirements are small: a health check on every service, no fixed container names, no published ports, and backward-compatible migrations. Those are worth having anyway, and they make a later move to more servers easier.

Keep reading

Tell us what you want to build.

A product, a website, a search problem or a system that should work better. We reply with a plain answer and the first step.

A few sentences are enough (at least 20 characters).

We use your details only to answer your inquiry. See our privacy policy.