From d2a21afcfec5c9654e14e5d035c80cc26a391741 Mon Sep 17 00:00:00 2001 From: Jan Rundshagen Date: Sat, 29 Mar 2025 13:11:47 +0100 Subject: [PATCH] docs: update documentation with new sections and improve clarity --- .gitignore | 2 ++ CONTRIBUTING.md | 4 +-- SECURITY.md | 2 +- docs/arguments.md | 53 ++++++++++++++++++++++++------ docs/container-selection.md | 12 +++---- docs/http-api-mode.md | 4 ++- docs/index.md | 3 +- docs/introduction.md | 3 +- docs/lifecycle-hooks.md | 25 +++++++------- docs/linked-containers.md | 2 ++ docs/metrics.md | 4 ++- docs/notifications.md | 7 ++-- docs/private-registries.md | 46 +++++++++++++++----------- docs/remote-hosts.md | 2 ++ docs/running-multiple-instances.md | 10 +++--- docs/secure-connections.md | 2 ++ docs/stop-signals.md | 2 ++ docs/updating.md | 8 ++--- docs/usage-overview.md | 8 +++-- mkdocs.yml | 2 +- 20 files changed, 128 insertions(+), 73 deletions(-) diff --git a/.gitignore b/.gitignore index aa4f339..fd6098c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ coverage.out docs/assets/wasm_exec.js docs/assets/*.wasm .vscode/settings.json + +.env diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 37f1b1e..bb49839 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,7 @@ You can check your current version of the go language as follows: ```bash ~ $ go version - go version go1.22.x darwin/amd64 + go version go1.24.x darwin/amd64 ``` ## Checking out the code @@ -44,5 +44,5 @@ To build a Watchtower image of your own, use the self-contained Dockerfiles. As e.g.: ```bash -sudo docker build . -f dockerfiles/Dockerfile.dev-self-contained -t containrrr/watchtower # to build an image from local files +sudo docker build . -f dockerfiles/Dockerfile.dev-self-contained -t beatkind/watchtower # to build an image from local files ``` diff --git a/SECURITY.md b/SECURITY.md index f217592..34679e1 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,3 +1,3 @@ # Security Policy -Nothing here yet. We'll figure it out. Message me if you need something under: . +Nothing here yet. We'll figure it out. Message me if you need something under: . diff --git a/docs/arguments.md b/docs/arguments.md index 2966370..4378b88 100644 --- a/docs/arguments.md +++ b/docs/arguments.md @@ -1,3 +1,5 @@ +# Arguments + By default, watchtower will monitor all containers running within the Docker daemon to which it is pointed (in most cases this will be the local Docker daemon, but you can override it with the `--host` option described in the next section). However, you can restrict watchtower to monitoring a subset of the running containers by specifying the container names as arguments when @@ -33,14 +35,16 @@ Some arguments can also reference a file, in which case the contents of the file This can be used to avoid putting secrets in the configuration file or command line. The following arguments are currently supported (including their corresponding `WATCHTOWER_` environment variables): - - `notification-url` - - `notification-email-server-password` - - `notification-slack-hook-url` - - `notification-msteams-hook` - - `notification-gotify-token` - - `http-api-token` + +- `notification-url` +- `notification-email-server-password` +- `notification-slack-hook-url` +- `notification-msteams-hook` +- `notification-gotify-token` +- `http-api-token` ### Example docker-compose usage + ```yaml secrets: access_token: @@ -55,6 +59,7 @@ services: ``` ## Help + Shows documentation about the supported flags. ```text @@ -65,6 +70,7 @@ Environment Variable: N/A ``` ## Time Zone + Sets the time zone to be used by WatchTower's logs and the optional Cron scheduling argument (--schedule). If this environment variable is not set, Watchtower will use the default time zone: UTC. To find out the right value, see [this list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), find your location and use the value in _TZ Database Name_, e.g _Europe/Rome_. The timezone can alternatively be set by volume mounting your hosts /etc/localtime file. `-v /etc/localtime:/etc/localtime:ro` @@ -76,6 +82,7 @@ Environment Variable: TZ ``` ## Cleanup + Removes old images after updating. When this flag is specified, watchtower will remove the old image after restarting a container with a new image. Use this option to prevent the accumulation of orphaned images on your system as containers are updated. ```text @@ -86,6 +93,7 @@ Environment Variable: WATCHTOWER_CLEANUP ``` ## Remove anonymous volumes + Removes anonymous volumes after updating. When this flag is specified, watchtower will remove all anonymous volumes from the container before restarting with a new image. Named volumes will not be removed! ```text @@ -96,6 +104,7 @@ Environment Variable: WATCHTOWER_REMOVE_VOLUMES ``` ## Debug + Enable debug mode with verbose logging. !!! note "Notes" @@ -110,6 +119,7 @@ Environment Variable: WATCHTOWER_DEBUG ``` ## Trace + Enable trace mode with very verbose logging. Caution: exposes credentials! !!! note "Notes" @@ -146,6 +156,7 @@ Environment Variable: WATCHTOWER_LOG_FORMAT ``` ## ANSI colors + Disable ANSI color escape codes in log output. ```text @@ -156,6 +167,7 @@ Environment Variable: NO_COLOR ``` ## Docker host + Docker daemon socket to connect to. Can be pointed at a remote Docker host by specifying a TCP endpoint as "tcp://hostname:port". ```text @@ -166,6 +178,7 @@ Environment Variable: DOCKER_HOST ``` ## Docker API version + The API version to use by the Docker client for connecting to the Docker daemon. The minimum supported version is 1.44. ```text @@ -176,6 +189,7 @@ Environment Variable: DOCKER_API_VERSION ``` ## Include restarting + Will also include restarting containers. ```text @@ -186,6 +200,7 @@ Environment Variable: WATCHTOWER_INCLUDE_RESTARTING ``` ## Include stopped + Will also include created and exited containers. ```text @@ -196,6 +211,7 @@ Environment Variable: WATCHTOWER_INCLUDE_STOPPED ``` ## Revive stopped + Start any stopped containers that have had their image updated. This argument is only usable with the `--include-stopped` argument. ```text @@ -206,6 +222,7 @@ Environment Variable: WATCHTOWER_REVIVE_STOPPED ``` ## Poll interval + Poll interval (in seconds). This value controls how frequently watchtower will poll for new images. Either `--schedule` or a poll interval can be defined, but not both. ```text @@ -216,6 +233,7 @@ Environment Variable: WATCHTOWER_POLL_INTERVAL ``` ## Filter by enable label + Monitor and update containers that have a `com.centurylinklabs.watchtower.enable` label set to true. ```text @@ -226,11 +244,13 @@ Environment Variable: WATCHTOWER_LABEL_ENABLE ``` ## Filter by disable label + __Do not__ Monitor and update containers that have `com.centurylinklabs.watchtower.enable` label set to false and no `--label-enable` argument is passed. Note that only one or the other (targeting by enable label) can be used at the same time to target containers. ## Filter by disabling specific container names + Monitor and update containers whose names are not in a given set of names. This can be used to exclude specific containers, when setting labels is not an option. @@ -244,6 +264,7 @@ Environment Variable: WATCHTOWER_DISABLE_CONTAINERS ``` ## Without updating containers + Will only monitor for new images, send notifications and invoke the [pre-check/post-check hooks](https://watchtower.devcdn.net/lifecycle-hooks/), but will __not__ update the containers. @@ -276,8 +297,10 @@ Environment Variable: WATCHTOWER_LABEL_TAKE_PRECEDENCE ``` ## Without restarting containers + Do not restart containers after updating. This option can be useful when the start of the containers is managed by an external system such as systemd. + ```text Argument: --no-restart Environment Variable: WATCHTOWER_NO_RESTART @@ -286,6 +309,7 @@ Environment Variable: WATCHTOWER_NO_RESTART ``` ## Without pulling new images + Do not pull new images. When this flag is specified, watchtower will not attempt to pull new images from the registry. Instead it will only monitor the local image cache for changes. Use this option if you are building new images directly on the Docker host without pushing @@ -304,6 +328,7 @@ Note that no-pull can also be specified on a per-container basis with the See [With label taking precedence over arguments](#With-label-taking-precedence-over-arguments) for behavior when both argument and label are set ## Without sending a startup message + Do not send a message after watchtower started. Otherwise there will be an info-level notification. ```text @@ -324,6 +349,7 @@ Environment Variable: WATCHTOWER_RUN_ONCE ``` ## HTTP API Mode + Runs Watchtower in HTTP API mode, only allowing image updates to be triggered by an HTTP request. For details see [HTTP API](https://watchtower.devcdn.net/http-api-mode). @@ -335,6 +361,7 @@ Environment Variable: WATCHTOWER_HTTP_API_UPDATE ``` ## HTTP API Token + Sets an authentication token to HTTP API requests. Can also reference a file, in which case the contents of the file are used. @@ -346,6 +373,7 @@ Environment Variable: WATCHTOWER_HTTP_API_TOKEN ``` ## HTTP API periodic polls + Keep running periodic updates if the HTTP API mode is enabled, otherwise the HTTP API would prevent periodic polls. ```text @@ -356,6 +384,7 @@ Environment Variable: WATCHTOWER_HTTP_API_PERIODIC_POLLS ``` ## Filter by scope + Update containers that have a `com.centurylinklabs.watchtower.scope` label set with the same value as the given argument. This enables [running multiple instances](https://watchtower.devcdn.net/running-multiple-instances). @@ -372,6 +401,7 @@ Environment Variable: WATCHTOWER_SCOPE ``` ## HTTP API Metrics + Enables a metrics endpoint, exposing prometheus metrics via HTTP. See [Metrics](metrics.md) for details. ```text @@ -382,6 +412,7 @@ Environment Variable: WATCHTOWER_HTTP_API_METRICS ``` ## Scheduling + [Cron expression](https://pkg.go.dev/github.com/robfig/cron@v1.2.0?tab=doc#hdr-CRON_Expression_Format) in 6 fields (rather than the traditional 5) which defines when and how often to check for new images. Either `--interval` or the schedule expression can be defined, but not both. An example: `--schedule "0 0 4 * * *"` @@ -393,6 +424,7 @@ Environment Variable: WATCHTOWER_SCHEDULE ``` ## Rolling restart + Restart one image at time instead of stopping and starting all at once. Useful in conjunction with lifecycle hooks to implement zero-downtime deploy. @@ -404,6 +436,7 @@ Environment Variable: WATCHTOWER_ROLLING_RESTART ``` ## Wait until timeout + Timeout before the container is forcefully stopped. When set, this option will change the default (`10s`) wait time to the given value. An example: `--stop-timeout 30s` will set the timeout to 30 seconds. ```text @@ -455,10 +488,10 @@ Writes the session results to STDOUT using a stable, machine-readable format (in Alias for: ```text - --notification-url logger:// - --notification-log-stdout - --notification-report - --notification-template porcelain.VERSION.summary-no-log +--notification-url logger:// +--notification-log-stdout +--notification-report +--notification-template porcelain.VERSION.summary-no-log Argument: --porcelain, -P Environment Variable: WATCHTOWER_PORCELAIN diff --git a/docs/container-selection.md b/docs/container-selection.md index 81d7971..2465443 100644 --- a/docs/container-selection.md +++ b/docs/container-selection.md @@ -1,11 +1,13 @@ +# Container Selection + By default, watchtower will watch all containers. However, sometimes only some containers should be updated. There are two options: -- **Fully exclude**: You can choose to exclude containers entirely from being watched by watchtower. -- **Monitor only**: In this mode, watchtower checks for container updates, sends notifications and invokes the [pre-check/post-check hooks](https://watchtower.devcdn.net/lifecycle-hooks/) on the containers but does **not** perform the update. +- **Fully exclude**: You can choose to exclude containers entirely from being watched by watchtower. +- **Monitor only**: In this mode, watchtower checks for container updates, sends notifications and invokes the [pre-check/post-check hooks](https://watchtower.devcdn.net/lifecycle-hooks/) on the containers but does **not** perform the update. -## Full Exclude +## Full Exclude If you need to exclude some containers, set the _com.centurylinklabs.watchtower.enable_ label to `false`. For clarity this should be set **on the container(s)** you wish to be ignored, this is not set on watchtower. @@ -23,7 +25,6 @@ If you need to exclude some containers, set the _com.centurylinklabs.watchtower. === "docker-compose" ``` yaml - version: "3" services: someimage: container_name: someimage @@ -47,7 +48,6 @@ If instead you want to [only include containers with the enable label](https://w === "docker-compose" ``` yaml - version: "3" services: someimage: container_name: someimage @@ -78,4 +78,4 @@ Or, it can be specified as part of the `docker run` command line: docker run -d --label=com.centurylinklabs.watchtower.monitor-only=true someimage ``` -When the label is specified on a container, watchtower treats that container exactly as if [`WATCHTOWER_MONITOR_ONLY`](https://watchtower.devcdn.net/arguments/#without_updating_containers) was set, but the effect is limited to the individual container. +When the label is specified on a container, watchtower treats that container exactly as if [`WATCHTOWER_MONITOR_ONLY`](https://watchtower.devcdn.net/arguments/#without_updating_containers) was set, but the effect is limited to the individual container. diff --git a/docs/http-api-mode.md b/docs/http-api-mode.md index 9702096..39fda1d 100644 --- a/docs/http-api-mode.md +++ b/docs/http-api-mode.md @@ -1,3 +1,5 @@ +# HTTP API Mode + Watchtower provides an HTTP API mode that enables an HTTP endpoint that can be requested to trigger container updating. The current available endpoint list is: - `/v1/update` - triggers an update for all of the containers monitored by this Watchtower instance. @@ -7,7 +9,7 @@ Watchtower provides an HTTP API mode that enables an HTTP endpoint that can be r To enable this mode, use the flag `--http-api-update`. For example, in a Docker Compose config file: ```yaml -version: '3' + services: app-monitored-by-watchtower: diff --git a/docs/index.md b/docs/index.md index 343d501..e7a8ee6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -32,7 +32,7 @@ !!! note "Watchtower fork" This is a fork of the really nice project from [containrrr](https://github.com/containrrr) called [watchtower](https://github.com/containrrr/watchtower). - I am not the original author of this project. I just forked it to make some changes to it and keep it up-to-date as properly as I can. + I am not the original author of this project. I just forked it to make some changes to it and keep it up-to-date as properly as I can. Contributions, tips and hints are welcome. Just open an issue or a pull request. Please be aware that I am by no means a professional developer. I am just a Platform Engineer. ## Quick Start @@ -54,7 +54,6 @@ the following command: === "docker-compose.yml" ```yaml - version: "3" services: watchtower: image: beatkind/watchtower diff --git a/docs/introduction.md b/docs/introduction.md index 7158ecd..f2f131d 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -1,3 +1,5 @@ +# Introduction + Watchtower is an application that will monitor your 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. With watchtower you can update the running version of your containerized app simply by pushing a new image to the Docker Hub or your own image registry. Watchtower will pull down your new image, gracefully shut down your existing container and restart it with the same options that were used when it was deployed initially. @@ -12,4 +14,3 @@ CONTAINER ID IMAGE STATUS PORTS ``` Every day watchtower will pull the latest _centurylink/wetty-cli_ image and compare it to the one that was used to run the "wetty" container. If it sees that the image has changed it will stop/remove the "wetty" container and then restart it using the new image and the same `docker run` options that were used to start the container initially (in this case, that would include the `-p 8080:3000` port mapping). - diff --git a/docs/lifecycle-hooks.md b/docs/lifecycle-hooks.md index 0c1e4e0..a7d3b11 100644 --- a/docs/lifecycle-hooks.md +++ b/docs/lifecycle-hooks.md @@ -1,10 +1,10 @@ -## Executing commands before and after updating +# Executing commands before and after updating -!!! note +!!! note These are shell commands executed with `sh`, and therefore require the container to provide the `sh` executable. -> **DO NOTE**: If the container is not running then lifecycle hooks can not run and therefore +> **DO NOTE**: If the container is not running then lifecycle hooks can not run and therefore > the update is executed without running any lifecycle hooks. It is possible to execute _pre/post\-check_ and _pre/post\-update_ commands @@ -19,14 +19,14 @@ This feature is disabled by default. To enable it, you need to set the option `--enable-lifecycle-hooks` on the command line, or set the environment variable `WATCHTOWER_LIFECYCLE_HOOKS` to `true`. -### Specifying update commands +## Specifying update commands The commands are specified using docker container labels, the following are currently available: | Type | Docker Container Label | -| ----------- | ------------------------------------------------------ | +| ----------- | ------------------------------------------------------ | | Pre Check | `com.centurylinklabs.watchtower.lifecycle.pre-check` | -| Pre Update | `com.centurylinklabs.watchtower.lifecycle.pre-update` | +| Pre Update | `com.centurylinklabs.watchtower.lifecycle.pre-update` | | Post Update | `com.centurylinklabs.watchtower.lifecycle.post-update` | | Post Check | `com.centurylinklabs.watchtower.lifecycle.post-check` | @@ -34,7 +34,7 @@ These labels can be declared as instructions in a Dockerfile (with some example the `docker run` command line: === "Dockerfile" - ```docker + ```docker LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="/sync.sh" LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="/dump-data.sh" LABEL com.centurylinklabs.watchtower.lifecycle.post-update="/restore-data.sh" @@ -42,7 +42,7 @@ the `docker run` command line: ``` === "docker run" - ```bash + ```bash docker run -d \ --label=com.centurylinklabs.watchtower.lifecycle.pre-check="/sync.sh" \ --label=com.centurylinklabs.watchtower.lifecycle.pre-update="/dump-data.sh" \ @@ -50,20 +50,21 @@ the `docker run` command line: someimage --label=com.centurylinklabs.watchtower.lifecycle.post-check="/send-heartbeat.sh" \ ``` -### Timeouts +## Timeouts + The timeout for all lifecycle commands is 60 seconds. After that, a timeout will occur, forcing Watchtower to continue the update loop. -#### Pre- or Post-update timeouts +### Pre- or Post-update timeouts For the `pre-update` or `post-update` lifecycle command, it is possible to override this timeout to allow the script to finish before forcefully killing it. This is done by adding the label `com.centurylinklabs.watchtower.lifecycle.pre-update-timeout` or post-update-timeout respectively followed by the timeout expressed in minutes. -If the label value is explicitly set to `0`, the timeout will be disabled. +If the label value is explicitly set to `0`, the timeout will be disabled. -### Execution failure +## Execution failure The failure of a command to execute, identified by an exit code different than 0 or 75 (EX_TEMPFAIL), will not prevent watchtower from updating the container. Only an error diff --git a/docs/linked-containers.md b/docs/linked-containers.md index c7e9be8..b7e760c 100644 --- a/docs/linked-containers.md +++ b/docs/linked-containers.md @@ -1,3 +1,5 @@ +# Linked Containers + Watchtower will detect if there are links between any of the running containers and ensures that things are stopped/started in a way that won't break any of the links. If an update is detected for one of the dependencies in a group of linked containers, watchtower will stop and start all of the containers in the correct order so that the application comes back up correctly. For example, imagine you were running a _mysql_ container and a _wordpress_ container which had been linked to the _mysql_ container. If watchtower were to detect that the _mysql_ container required an update, it would first shut down the linked _wordpress_ container followed by the _mysql_ container. When restarting the containers it would handle _mysql_ first and then _wordpress_ to ensure that the link continued to work. diff --git a/docs/metrics.md b/docs/metrics.md index 480d7c6..237401b 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -1,3 +1,5 @@ +# Watchtower Metrics + !!! warning "Experimental feature" This feature was added in v1.0.4 and is still considered experimental. If you notice any strange behavior, please raise a ticket in the repository issues. @@ -9,7 +11,7 @@ as well as creating a port mapping for your container for port `8080`. The metrics API endpoint is `/v1/metrics`. -## Available Metrics +## Available Metrics | Name | Type | Description | | ------------------------------- | ------- | --------------------------------------------------------------------------- | diff --git a/docs/notifications.md b/docs/notifications.md index f4e0bf1..d197ccb 100644 --- a/docs/notifications.md +++ b/docs/notifications.md @@ -144,7 +144,7 @@ Example using a custom report template that always sends a session report after === "docker-compose" ``` yaml - version: "3" + services: watchtower: image: beatkind/watchtower @@ -206,7 +206,7 @@ If watchtower is started with `notify-upgrade` as it's first argument, it will g === "docker-compose.yml" ```yaml - version: "3" + services: watchtower: image: beatkind/watchtower @@ -234,7 +234,7 @@ You can then copy this file from the container (a message with the full command === "docker-compose.yml" ```yaml - version: "3" + services: watchtower: image: beatkind/watchtower @@ -283,7 +283,6 @@ The following example assumes, that your domain is called `your-domain.com` and Example including an SMTP relay: ```yaml -version: '3.8' services: watchtower: image: beatkind/watchtower:latest diff --git a/docs/private-registries.md b/docs/private-registries.md index 3a3ba43..d3e54a7 100644 --- a/docs/private-registries.md +++ b/docs/private-registries.md @@ -1,6 +1,8 @@ +# Private Registries + Watchtower supports private Docker image registries. In many cases, accessing a private registry requires a valid username and password (i.e., _credentials_). In order to operate in such an -environment, watchtower needs to know the credentials to access the registry. +environment, watchtower needs to know the credentials to access the registry. The credentials can be provided to watchtower in a configuration file called `config.json`. There are two ways to generate this configuration file: @@ -8,7 +10,8 @@ There are two ways to generate this configuration file: * The configuration file can be created manually. * Call `docker login ` and share the resulting configuration file. -### Create the configuration file manually +## Create the configuration file manually + Create a new configuration file with the following syntax and a base64 encoded username and password `auth` string: @@ -31,7 +34,7 @@ password `auth` string: In this special case, the registry domain does not have to be specified in `docker run` or `docker-compose`. Like Docker, Watchtower will use the Docker Hub registry and its credentials when no registry domain is specified. - + Watchtower will recognize credentials with `` `index.docker.io`, but the Docker CLI will not. @@ -40,7 +43,7 @@ password `auth` string: in both `config.json` and the `docker run` command or `docker-compose` file. Valid hosts are `localhost[:PORT]`, `HOST:PORT`, or any multi-part `domain.name` or IP-address with or without a port. - + Examples: * `localhost` -> `localhost/myimage` * `127.0.0.1` -> `127.0.0.1/myimage:mytag` @@ -66,7 +69,7 @@ When the watchtower Docker container is started, the created configuration file docker run [...] -v /config.json:/config.json beatkind/watchtower ``` -### Share the Docker configuration file +## Share the Docker configuration file To pull an image from a private registry, `docker login` needs to be called first, to get access to the registry. The provided credentials are stored in a configuration file called `/.docker/config.json`. @@ -92,14 +95,15 @@ services: ... ``` -#### Docker Config path +### Docker Config path + By default, watchtower will look for the `config.json` file in `/`, but this can be changed by setting the `DOCKER_CONFIG` environment variable to the directory path where your config is located. This is useful for setups where the config.json file is changed while the watchtower instance is running, as the changes will not be picked up for a mounted file if the inode changes. Example usage: ```yaml version: "3.4" -services: +services: watchtower: image: beatkind/watchtower environment: @@ -110,6 +114,7 @@ services: ``` ## Credential helpers + Some private Docker registries (the most prominent probably being AWS ECR) use non-standard ways of authentication. To be able to use this together with watchtower, we need to use a credential helper. @@ -117,6 +122,7 @@ To keep the image size small we've decided to not include any helpers in the wat helper in a separate container and mount it using volumes. ### Example + Example implementation for use with [amazon-ecr-credential-helper](https://github.com/awslabs/amazon-ecr-credential-helper): Use the dockerfile below to build the [amazon-ecr-credential-helper](https://github.com/awslabs/amazon-ecr-credential-helper), @@ -125,30 +131,30 @@ in a volume that may be mounted onto your watchtower container. 1. Create the Dockerfile (contents below): ```Dockerfile FROM golang:1.20 - + ENV GO111MODULE off ENV CGO_ENABLED 0 ENV REPO github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login - + RUN go get -u $REPO - + RUN rm /go/bin/docker-credential-ecr-login - + RUN go build \ -o /go/bin/docker-credential-ecr-login \ /go/src/$REPO - + WORKDIR /go/bin/ ``` 2. Use the following commands to build the aws-ecr-dock-cred-helper and store it's output in a volume: ```bash # Create a volume to store the command (once built) - docker volume create helper - + docker volume create helper + # Build the container docker build -t aws-ecr-dock-cred-helper . - + # Build the command and store it in the new volume in the /go/bin directory. docker run -d --rm --name aws-cred-helper \ --volume helper:/go/bin aws-ecr-dock-cred-helper @@ -188,20 +194,20 @@ in a volume that may be mounted onto your watchtower container. - PATH=$PATH:/go/bin - AWS_REGION=us-west-1 volumes: - helper: + helper: external: true ``` A few additional notes: -1. With docker-compose the volume (helper, in this case) MUST be set to `external: true`, otherwise docker-compose +1. With docker-compose the volume (helper, in this case) MUST be set to `external: true`, otherwise docker-compose will preface it with the directory name. -2. Note that "credsStore" : "ecr-login" is needed - and in theory if you have that you can remove the +2. Note that "credsStore" : "ecr-login" is needed - and in theory if you have that you can remove the credHelpers section -3. I have this running on an EC2 instance that has credentials assigned to it - so no keys are needed; however, +3. I have this running on an EC2 instance that has credentials assigned to it - so no keys are needed; however, you may need to include the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables as well. -4. An alternative to adding the various variables is to create a ~/.aws/config and ~/.aws/credentials files and +4. An alternative to adding the various variables is to create a ~/.aws/config and ~/.aws/credentials files and place the settings there, then mount the ~/.aws directory to / in the container. diff --git a/docs/remote-hosts.md b/docs/remote-hosts.md index b1808d8..d6b4b95 100644 --- a/docs/remote-hosts.md +++ b/docs/remote-hosts.md @@ -1,3 +1,5 @@ +# Remote Docker Hosts + By default, watchtower is set-up to monitor the local Docker daemon (the same daemon running the watchtower container itself). However, it is possible to configure watchtower to monitor a remote Docker endpoint. When starting the watchtower container you can specify a remote Docker endpoint with either the `--host` flag or the `DOCKER_HOST` environment variable: ```bash diff --git a/docs/running-multiple-instances.md b/docs/running-multiple-instances.md index 470b9e1..fc1e6d6 100644 --- a/docs/running-multiple-instances.md +++ b/docs/running-multiple-instances.md @@ -1,4 +1,4 @@ -By default, Watchtower will clean up other instances and won't allow multiple instances running on the same Docker host or swarm. It is possible to override this behavior by defining a [scope](https://watchtower.devcdn.net/arguments/#filter_by_scope) to each running instance. +By default, Watchtower will clean up other instances and won't allow multiple instances running on the same Docker host or swarm. It is possible to override this behavior by defining a [scope](https://watchtower.devcdn.net/arguments/#filter_by_scope) to each running instance. !!! note - Multiple instances can't run with the same scope; @@ -10,7 +10,7 @@ To define an instance monitoring scope, use the `--scope` argument or the `WATCH For example, in a Docker Compose config file: ```yaml -version: '3' + services: app-with-scope: @@ -21,7 +21,7 @@ services: image: beatkind/watchtower volumes: [ "/var/run/docker.sock:/var/run/docker.sock" ] command: --interval 30 --scope myscope - labels: [ "com.centurylinklabs.watchtower.scope=myscope" ] + labels: [ "com.centurylinklabs.watchtower.scope=myscope" ] unscoped-app-a: image: myapps/app-a @@ -29,11 +29,11 @@ services: unscoped-app-b: image: myapps/app-b labels: [ "com.centurylinklabs.watchtower.scope=none" ] - + unscoped-app-c: image: myapps/app-b labels: [ "com.centurylinklabs.watchtower.scope=" ] - + unscoped-watchtower: image: beatkind/watchtower volumes: [ "/var/run/docker.sock:/var/run/docker.sock" ] diff --git a/docs/secure-connections.md b/docs/secure-connections.md index debb59e..4b73bd7 100644 --- a/docs/secure-connections.md +++ b/docs/secure-connections.md @@ -1,3 +1,5 @@ +# Secure Connections + Watchtower is also capable of connecting to Docker endpoints which are protected by SSL/TLS. If you've used _docker-machine_ to provision your remote Docker host, you simply need to volume mount the certificates generated by _docker-machine_ into the watchtower container and optionally specify `--tlsverify` flag. The _docker-machine_ certificates for a particular host can be located by executing the `docker-machine env` command for the desired host (note the values for the `DOCKER_HOST` and `DOCKER_CERT_PATH` environment variables that are returned from this command). The directory containing the certificates for the remote host needs to be mounted into the watchtower container at _/etc/ssl/docker_. diff --git a/docs/stop-signals.md b/docs/stop-signals.md index f4b4f1d..bf2706b 100644 --- a/docs/stop-signals.md +++ b/docs/stop-signals.md @@ -1,3 +1,5 @@ +# Stop signals + When watchtower detects that a running container needs to be updated it will stop the container by sending it a SIGTERM signal. If your container should be shutdown with a different signal you can communicate this to watchtower by setting a label named _com.centurylinklabs.watchtower.stop-signal_ with the value of the desired signal. diff --git a/docs/updating.md b/docs/updating.md index 4b95775..ded9bdd 100644 --- a/docs/updating.md +++ b/docs/updating.md @@ -1,6 +1,6 @@ -## Updating Watchtower +# Updating Watchtower -If watchtower is monitoring the same Docker daemon under which the watchtower container itself is running (i.e. if you -volume-mounted `/var/run/docker.sock` into the watchtower container) then it has the ability to update itself. -If a new version of the `beatkind/watchtower` image is pushed to the Docker Hub, your watchtower will pull down the +If watchtower is monitoring the same Docker daemon under which the watchtower container itself is running (i.e. if you +volume-mounted `/var/run/docker.sock` into the watchtower container) then it has the ability to update itself. +If a new version of the `beatkind/watchtower` image is pushed to the Docker Hub, your watchtower will pull down the new image and restart itself automatically. diff --git a/docs/usage-overview.md b/docs/usage-overview.md index a5e213c..1531ba4 100644 --- a/docs/usage-overview.md +++ b/docs/usage-overview.md @@ -1,3 +1,5 @@ +# Usage + Watchtower is itself packaged as a Docker container so installation is as simple as pulling the `beatkind/watchtower` image. If you are using ARM based architecture, pull the appropriate `beatkind/watchtower:armhf-` image from the [beatkind Docker Hub](https://hub.docker.com/r/beatkind/watchtower/tags/). Since the watchtower code needs to interact with the Docker API in order to monitor the running containers, you need to mount _/var/run/docker.sock_ into the container with the `-v` flag when you run it. @@ -41,8 +43,8 @@ docker run -d \ If you mount `config.json` in the manner above, changes from the host system will (generally) not be propagated to the running container. Mounting files into the Docker daemon uses bind mounts, which are based on inodes. Most applications (including `docker login` and `vim`) will not directly edit the file, but instead make a copy and replace - the original file, which results in a new inode which in turn _breaks_ the bind mount. - **As a workaround**, you can create a symlink to your `config.json` file and then mount the symlink in the container. + the original file, which results in a new inode which in turn _breaks_ the bind mount. + **As a workaround**, you can create a symlink to your `config.json` file and then mount the symlink in the container. The symlinked file will always have the same inode, which keeps the bind mount intact and will ensure changes to the original file are propagated to the running container (regardless of the inode of the source file!). @@ -52,7 +54,7 @@ from a private repo on the GitHub Registry and monitors it with watchtower. Note to 30s rather than the default 24 hours. ```yaml -version: "3" + services: cavo: image: ghcr.io//: diff --git a/mkdocs.yml b/mkdocs.yml index f6aa742..8c880d0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,5 +1,5 @@ site_name: Watchtower -site_url: https://containrrr.dev/watchtower/ +site_url: https://watchtower.devcdn.net/ repo_url: https://github.com/beatkind/watchtower/ edit_uri: edit/main/docs/ theme: