'All' Compose File
The Scenario
We want to push a standard compose file to all machines, which enables some standardization across the board.
We're wanting to standardize;
Automatic updates for specific containers
Server monitoring
Server security
Requirements
NetData cloud account (free)
Docker installed on all servers
A way to push the Compose file to each server (I recommend Portainer Edge Stacks)
Recommendations
Portainer for managing docker, refer to https://github.com/trentnbauer/agg-docs/blob/main/guides/mini-guides/broken-reference/README.md for a deployment guide
Please note that WatchTower is NOT a supported method for updating docker containers and automatic updates can cause issues. Please ensure you have backups of your data in case you need to roll back. I would recommend following my https://github.com/trentnbauer/agg-docs/blob/main/guides/mini-guides/broken-reference/README.md documentation as this includes a much safer solution for updating containers.
Ignoring that, I am using WatchTower to update Portainer in my environment as I am unable to update it without doing it via the CLI. In general, this is the only time I would suggest this as a solution
Solution
We're going to create a Docker Compose file to be installed on all machines (this expects Ubuntu, but may work on other Linux distros)
This compose file will container
NetData (server monitoring and alerts)
Fail2Ban (security for SSH)
WatchTower
1 instance for daily updates
1 instance for weekly updates
Any container that requires updating will need the relevant WatchTower label added to enable updates
Watchtower Tags
Please ensure that your container version is 'latest' to enable auto-updates. Enabling a version tag (eg v1.1.1) will not allow for auto updates. eg netdata:latest
Docker Compose
Add the below to the compose file, at bottom of each container you wish to update. Ensure that the 'labels:' line is at the same spot as image, ports, volumes etc.
CLI
Add the below line to the end of your docker run
command
Portainer
Edit your container and scroll down to advanced settings
Select Labels
Click 'Add label'
Add one of the below\
NameValuecom.centurylinklabs.watchtower.label
daily
com.centurylinklabs.watchtower.label
weekly
Compose File
Don't copy paste the file, there are some entries you need to fill
Last updated