selfhosted-apps-docker/watchtower/readme.md

80 lines
2.1 KiB
Markdown
Raw Normal View History

2020-04-09 22:52:11 +00:00
# Watchtower in docker
2020-05-18 22:49:18 +00:00
###### guide-by-example
2020-04-09 22:52:11 +00:00
2020-04-26 00:05:21 +00:00
![logo](https://i.imgur.com/xXS2bzZ.png)
# Purpose
2020-04-09 22:52:11 +00:00
2020-05-10 21:39:40 +00:00
Automatic updates of docker containers.
2020-04-09 22:52:11 +00:00
* [Github](https://github.com/containrrr/watchtower)
* [DockerHub image used](https://hub.docker.com/r/containrrr/watchtower)
2020-05-10 21:36:32 +00:00
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.
2020-04-26 00:05:21 +00:00
# Files and directory structure
```
2020-05-01 09:38:43 +00:00
/home/
└── ~/
└── docker/
└── watchtower/
2020-05-10 21:36:32 +00:00
├── .env
└── docker-compose.yml
2020-04-26 00:05:21 +00:00
```
2020-05-22 16:05:03 +00:00
* `.env` - a file containing environment variables for docker compose
2020-05-22 16:22:45 +00:00
* `docker-compose.yml` - a docker compose file, telling docker how to run the container
2020-05-10 21:36:32 +00:00
Only these two files must be provided.
2020-04-26 00:05:21 +00:00
# docker-compose
2020-05-22 16:05:03 +00:00
Scheduled to run every saturday at midnight using environment variable.</br>
2020-04-27 21:01:48 +00:00
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).
2020-04-26 00:05:21 +00:00
`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
2020-05-10 21:39:40 +00:00
* [watchtower](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/watchtower)
updates itself automatically
2020-04-26 00:05:21 +00:00
2020-05-01 09:51:20 +00:00
* manual image update</br>
`docker-compose pull`</br>
`docker-compose up -d`</br>
`docker image prune`