You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.1 KiB
Markdown

4 years ago
# Watchtower in docker
4 years ago
###### guide-by-example
4 years ago
4 years ago
![logo](https://i.imgur.com/xXS2bzZ.png)
# Purpose
4 years ago
4 years ago
Automatic updates of docker containers.
4 years ago
* [Github](https://github.com/containrrr/watchtower)
* [DockerHub image used](https://hub.docker.com/r/containrrr/watchtower)
4 years ago
Watchtower is an application that will monitor the running Docker containers
and watch for changes to the images that those containers
were originally started from. If watchtower detects that an image has changed,
it will automatically restart the container using the new image.
As of now, Watchtower needs to always pull images to know if they changed.
This can be bandwidth intensive, so its scheduled checks should account for this.
4 years ago
# Files and directory structure
```
4 years ago
/home/
└── ~/
└── docker/
└── watchtower/
4 years ago
├── .env
└── docker-compose.yml
4 years ago
```
4 years ago
* `.env` - a file containing environment variables for docker compose
4 years ago
* `docker-compose.yml` - a docker compose file, telling docker how to run the container
4 years ago
Only these two files must be provided.
4 years ago
# docker-compose
4 years ago
Scheduled to run every saturday at midnight using environment variable.</br>
4 years ago
Heads up that not a typical cron format is used,
[seconds are the first digit](https://pkg.go.dev/github.com/robfig/cron@v1.2.0?tab=doc#hdr-CRON_Expression_Format).
4 years ago
`docker-compose.yml`
```yml
version: '3'
services:
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
hostname: watchtower
restart: unless-stopped
env_file: .env
volumes:
- /var/run/docker.sock:/var/run/docker.sock
```
`.env`
```bash
# GENERAL
# WATCHTOWER
WATCHTOWER_SCHEDULE=0 0 0 * * SAT
WATCHTOWER_CLEANUP=true
WATCHTOWER_TIMEOUT=30s
WATCHTOWER_DEBUG=false
WATCHTOWER_INCLUDE_STOPPED=false
```
# Update
4 years ago
* [watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower)
updates itself automatically
4 years ago
4 years ago
* manual image update</br>
`docker-compose pull`</br>
`docker-compose up -d`</br>
`docker image prune`