docker,

Docker Compose and the rolling update trick

Apr 19, 2023 · 1 min read · Post a comment

There are few tricks you could try if you want to achieve “100%” uptime / rolling update while using Docker Compose only. Not Docker Swarm, not K8s.

Prerequisites

  • Docker
  • Docker Compose

Solution

Step 1. Download the latest image, or the one you want to be deployed.

Step 2. Open the docker-compose.yml file and update the service image tag.

Step 3. Run the following command to bring another batch of new containers while keeping the old running:

docker compose up -d

Step 4. Scale down to the initial required number of containers. For instance from 10 to 5 containers:

docker compose scale app=5

Step 5. Verify.

docker compose ps

Step 6. Cleanup.

docker system prune

Conclusion

In case nothing works, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.