my-apprunning with a port mapping of
8090:3000. Your team uses CI/CD to roll out daily updates of the application. After your iteration is complete, you tag and push the image up to the registry. Watchtower has been configured to check the registry every 60 seconds. Once the 60-second iteration is complete, it detects the changes to the
my-appimage and pulls it down. Watchtower then gracefully shuts down the
my-appcontainer and then restarts it using the new image with the port mapping of
/var/run/docker.sockas a volume.
/var/run/docker.sockon the container. By default, Watchtower will check the image registry every 5 minutes. We want it to check every 30 seconds, so use the
-iflag with the poll interval set to
30. For a full listing of Watchtower’s options, please visit the GitHub readme.
docker run -d --name watchtower --restart always -v /var/run/docker.sock:/var/run/docker.sock v2tec/watchtower -i 30
index.htmlfile. For example:
<html> <header> <title>My We Page</title> </header> <body> This is my web page. </body></html>
/usr/share/nginx/html/index.htmlon the container. Set
/usr/share/nginx/htmlas the working directory.
FROM nginxCOPY index.html /usr/share/nginx/html/index.htmlWORKDIR /usr/share/nginx/html
docker build -t rivethead42/nginx -f Dockerfile .
docker logindocker push rivethead42/nginx
docker run -d —name my-web-page -p 80:80 —restart always rivethead42/nginx
docker psto make sure your container is running. After verifying that the container is running, you can wait a few minutes before making any changes. We’ll be checking the status of the container to verify that Watchtower has updated it.
my-web-pagecontainer has been running for a few minutes let’s make a change to the
<html> <header> <title>My We Page</title> </header> <body> This is my web page, how do you like it? </body></html>
docker psand note how long the container has been running by checking the status. Rebuild the image and push it to Docker Hub:
docker psdocker build -t rivethead42/nginx -f Dockerfile .docker push rivethead42/nginx
docker psto check the container status. When it is less than the original status, we know that Watchtower has worked its magic.