Welcome to 4X5MG Ham Radio blog. I like to try digital modes and other stuff…
Docker is really a thing these days.
In a nutsheel, it allows running web applications (like WordPress) in containers which work similar to Virtual Machines.
Or in Wikipedia words:
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines.
I decided to give it a try and I was stunned by the simplicity and the ease of use.
Along with Docker I installed Portainer which gives a nice user interface for managing the docker containers.
Portainer gives the option to update containers with new images and versions.
The only problem is to upgrade Portainer itself, you can’t do it unless you use the Docker CLI and using CLI isn’t fun for most of the people.
Watchtower comes to the rescue and it is a tool that runs as a container under Docker and check for new image updates for the containers you choose.
When it detects a change, it’ll pull the new image and recreate the container based on the updated image.
First login through SSH to your server.
Create new folder, I named it “Watchtower” and CD into the folder.
Use your favorite text editor to create new file called docker-compose.yml
Paste this code inside:
version: '3' services: watchtower: container_name: watchtower restart: always image: containrrr/watchtower environment: - WATCHTOWER_NOTIFICATIONS=email - [email protected] - [email protected] - WATCHTOWER_NOTIFICATION_EMAIL_SERVER=youremail.server - [email protected] - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=yourpassword - WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2 - TZ=yourtimezone volumes: - /var/run/docker.sock:/var/run/docker.sock command: --debug true --interval 1800 --cleanup true portainer
Change the settings you need, like the email server and username etc.
If you don’t want to use the email notifications you can delete all those lines.
You can set the timezone to adjust the time on the logs automatically (timezones can be found here)
The command parameters:
— debug Will show info on the logs.
— interval Sets the interval of checking the images (in seconds).
— cleanup Will delete the old images to clear some space.
Save the file and run:
docker-compose up -d
(You might need to use SUDO)
Now you can go to Portainer and check the logs of the new container called Watchtower.
Hope it was useful.