Docker Rollout: Zero Downtime Deployment for Docker Compose

Linux TLDR
Last Updated:
Reading time: 3 minutes

In this article, I’ll introduce you to a tool called “Docker Rollout“, which claims to update Docker Compose services with zero downtime. I’ve been testing it for a while, and to be honest, it can do that in a broader sense.

Well, there are some caveats in this tool that will be discussed later, but overall, you can use it to automate the manual process typically followed to achieve zero downtime during Docker container updates, such as scaling the service to twice the current number of instances with the updated image, waiting for the new container to be ready, and then removing the older container.

Now talking about the caveats, the service should not have “container_name” and “ports” defined in the “docker-compose.yml” file to avoid conflicts while scaling the services, so it’s best to use some sort of reverse proxy in the backend to handle this.

Additionally, it will increment the index number in the container (e.g., “web-1” -> “web-2“) during deployment. Overall, for most Docker images, it can update the Docker Compose with zero downtime, but images like Nextcloud switch to maintenance mode for a few seconds.

If I were to give you my personal opinion on my SysAdmin job, I would avoid using such tools and prefer the manual method for zero downtime deployment due to various requirements; however, in my Homelab, I use it freely without any second thoughts.

Now enough of the talk, let’s see how to install Docker Rollout on your Linux system and use it to update Docker Compose services with zero downtime.

Tutorial Details

DescriptionDocker Rollout
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisites
Internet RequiredYes

How to Install Docker Rollout on Linux

The installation process for Docker Rollout is quite simple and straightforward—all you have to do is open your Linux terminal and execute the following series of commands:

# Create a directory for Docker cli plugins.
$ mkdir -p ~/.docker/cli-plugins

# Download the Docker-rollout script to the Docker cli plugins directory.
$ curl https://raw.githubusercontent.com/wowu/docker-rollout/master/docker-rollout -o ~/.docker/cli-plugins/docker-rollout

# Make the script executable.
$ chmod +x ~/.docker/cli-plugins/docker-rollout

Once done, the “docker rollout” command becomes accessible.

How to Use Docker Rollout on Linux

To show you how to use Docker rollout to update Docker Compose services with zero downtime, I’ll use the following Docker Compose file:

version: "3.7"
services:
  my-web:
    image: username/nginx:v1
    networks:
      - localweb


  my-db:
    image: username/mysql:v1
    networks:
      - localweb

networks:
  localweb:

Assuming the Docker compose service is already running and version 2 is available for Nginx and MySQL containers, to implement this update, start by modifying the Docker compose file to set the image version to “v2“, then proceed to execute the following command:

📝
As of now, you don’t have the option to specify multiple Docker Compose services.
# It will update the Nginx container.
$ docker rollout -f docker-compose.yml my-web

# It will update the MySQL container.
$ docker rollout -f docker-compose.yml my-db

This command will scale all the containers to twice the current number using the updated image, wait for the new containers to be ready, and then remove the older containers. The status of the Docker Compose service can be monitored by using the “watch docker ps” command.

As you can see, this tool attempts to simplify the most inconvenient tasks for SysAdmins, but it’s not suitable for a professional environment due to a lack of customization and missing features. Hence, I ignore it in my job, but it could be a handy tool for my personal projects.

Now, if you have any questions or queries related to the article, do let me know in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.