
Photo by Alan on Unsplash
Updating Docker containers with Watchtower
Elevated View
Deploying microservices with Docker is relatively easy. With very little overhead, you can complete complex software installations and offer services in your company. However, controlling an infrastructure that has grown very quickly can often be far more time-consuming than the actual deployment. The progressive use of microservices, and with it the need to provision individually customized ecosystems within containers, leads to a confusing update jungle. If something goes wrong in the process, an unreachable service is in many ways less critical than a service that is vulnerable to attackers. Possible downtime is then supplemented by close monitoring and fallback strategies.
Regardless of how you manage your Docker containers – whether directly with Docker itself, with Docker Compose, or with one of the many other tools – you will want a working backup solution, and you will want to ensure that software updates are automated to the greatest extent possible. In this article, I look at Watchtower as an option for automatically updating your Docker containers.
Launching Watchtower
The initial setup for Watchtower is roughly equivalent in scope and complexity to changing a light bulb. If all tools are ready and the Docker daemon is running, you can launch Watchtower with:
docker run -d --name watchtower -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower
This command sends the launched container directly into the background with -d
(detach). You can freely select the name by specifying --name
and use the -v
option to include areas of the filesystem as a volume in the container's process group. The command includes the Docker daemon's communication socket because that is how Watchtower communicates and transmits its commands. The last argument of the command line passes in the Watchtower path in the Docker
Buy this article as PDF
(incl. VAT)