This repository is a small example showing how Watchtower and GitHub Actions can be used to update a running container, including instructions on how to setup an Ubuntu Server for this workflow.
The values in the setup steps and in this repository are based on an Azure Container Registry called julianzp.azurecr.io
.
The following steps assume a fresh Ubuntu 20.04 server with Internet access.
- Update server:
sudo apt update && sudo apt upgrade -y
- Get Docker setup script
curl -fsSL https://get.docker.com -o get-docker.sh
- Run Docker setup script
sudo sh get-docker.sh
- Add Docker group:
sudo groupadd docker
- Add current user to Docker group
sudo usermod -aG docker $USER
- If using an Azure Container Registry, install the Azure cli:
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- Login to the Azure cli:
az login
- Get an Azure Container Registry token:
az acr login --name julianzp.azurecr.io --expose-token
- Have Docker login to the Azure Container Registry:
docker login julianzp.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password $TOKEN
- Start your container:
docker run -d --name=hello -p 8080:80 julianzp.azurecr.io/julianzp/hello:latest
- Start watchtower:
docker run -d \
--name watchtower \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /home/user/.docker/config.json:/config.json \
containrrr/watchtower hello --debug -i 30
The arguments here specify:
-
check for updates every 30 seconds
-
only monitoring the "hello" container (that was started in Step 11) Also note this path
/home/user/.docker/config.json
will need to match what it is on your actual server.-
Add REGISTRY_USER and REGISTRY_PASSWORD secrets (these are the values for a user that can push images to the registry):
-
The action itself builds the Dockerfile in the repository and pushes it to the Azure Container Registry. Have a look here.
-