短描述

Watches your containers and automatically restarts them whenever their image is refreshed.

Docker Pull 命令

docker pull v2tec/watchtower

完整描述

[![Circle CI](https://circleci.com/gh/v2tec/watchtower.svg?style=shield)](https://circleci.com/gh/v2tec/watchtower)\n[![GoDoc](https://godoc.org/github.com/v2tec/watchtower?status.svg)](https://godoc.org/github.com/v2tec/watchtower)\n[![](https://images.microbadger.com/badges/image/v2tec/watchtower.svg)](https://microbadger.com/images/v2tec/watchtower "Get your own image badge on microbadger.com")\n[![Go Report Card](https://goreportcard.com/badge/github.com/v2tec/watchtower)](https://goreportcard.com/report/github.com/v2tec/watchtower)\n\nA process for watching your Docker containers and automatically restarting them whenever their base image is refreshed.\n\nPlease report any issues to [v2tec/watchtower](https://github.com/v2tec/watchtower).\n\n## Overview\n\nWatchtower 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.\n\nWith 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.\n\nFor example, let\'s say you were running watchtower along with an instance of *centurylink/wetty-cli* image:\n\n```bash\n$ docker ps\nCONTAINER ID IMAGE STATUS PORTS NAMES\n967848166a45 centurylink/wetty-cli Up 10 minutes 0.0.0.0:8080->3000/tcp wetty\n6cc4d2a9d1a5 v2tec/watchtower Up 15 minutes watchtower\n```\n\nEvery few mintutes 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).\n\n## Usage\n\nWatchtower is itself packaged as a Docker container so installation is as simple as pulling the `v2tec/watchtower` image.\n\nSince 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.\n\nRun the `watchtower` container with the following command:\n\n```bash\ndocker run -d \\\n --name watchtower \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n v2tec/watchtower\n```\n\nIf pulling images from private Docker registries, supply registry authentication credentials with the environment variables `REPO_USER` and `REPO_PASS`\nor by mounting the host\'s docker config file into the container (at the root of the container filesystem `/`).\n\n```bash\ndocker run -d \\\n --name watchtower \\\n -v /home/<user>/.docker/config.json:/config.json \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n v2tec/watchtower container_to_watch --debug\n```\n\nIf you mount the config file as described below, be sure to also prepend the url for the registry when starting up your watched image (you can omit the https://). Here is a complete docker-compose.yml file that starts up a docker container from a private repo at dockerhub and monitors it with watchtower. Note the command argument changing the interval to 30s rather than the default 5 minutes.\n\n```json\nversion: "3"\nservices:\n cavo:\n image: index.docker.io/<org>/<image>:<tag>\n ports:\n - "443:3443"\n - "80:3080"\n watchtower:\n image: v2tec/watchtower\n volumes:\n - /var/run/docker.sock:/var/run/docker.sock\n - /root/.docker/config.json:/config.json\n command: --interval 30\n```\n\n### Arguments\n\nBy 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 launching watchtower.\n\n```bash\ndocker run -d \\\n --name watchtower \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n v2tec/watchtower nginx redis\n```\n\nIn the example above, watchtower will only monitor the containers named "nginx" and "redis" for updates -- all of the other running containers will be ignored.\n\nWhen no arguments are specified, watchtower will monitor all running containers.\n\n### Options\n\nAny of the options described below can be passed to the watchtower process by setting them after the image name in the `docker run` string:\n\n```bash\ndocker run --rm v2tec/watchtower --help\n```\n\n* `--host, -h` Docker daemon socket to connect to. Defaults to "unix:///var/run/docker.sock" but can be pointed at a remote Docker host by specifying a TCP endpoint as "tcp://hostname:port". The host value can also be provided by setting the `DOCKER_HOST` environment variable.\n* `--interval, -i` Poll interval (in seconds). This value controls how frequently watchtower will poll for new images. Defaults to 300 seconds (5 minutes).\n* `--schedule, -s` [Cron expression](https://godoc.org/github.com/robfig/cron#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 could be defined, but not both. An example: `--schedule "0 0 4 * * *" ` \n* `--no-pull` 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 them to a registry.\n* `--label-enable` Watch containers where the `com.centurylinklabs.watchtower.enable` label is set to true.\n* `--cleanup` Remove 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.\n* `--tlsverify` Use TLS when connecting to the Docker socket and verify the server\'s certificate.\n* `--debug` Enable debug mode. When this option is specified you\'ll see more verbose logging in the watchtower log file.\n* `--help` Show documentation about the supported flags.\n\nSee below for options used to configure notifications.\n\n## Linked Containers\n\nWatchtower will detect if there are links between any of the running containers and ensure 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.\n\nFor 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.\n\n## Stopping Containers\n\nWhen watchtower detects that a running container needs to be updated it will stop the container by sending it a SIGTERM signal.\nIf 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.\n\nThis label can be coded directly into your image by using the `LABEL` instruction in your Dockerfile:\n\n```docker\nLABEL com.centurylinklabs.watchtower.stop-signal="SIGHUP"\n```\n\nOr, it can be specified as part of the `docker run` command line:\n\n```bash\ndocker run -d --label=com.centurylinklabs.watchtower.stop-signal=SIGHUP someimage\n```\n\n## Selectively Watching Containers\n\nBy default, watchtower will watch all containers.\nHowever, sometimes only some containers should be updated.\nIf you need to selectively watch containers, pass the --label-enable flag on startup and set the *com.centurylinklabs.watchtower.enable* label with a value of true for the containers you want to watch.\n\n```docker\nLABEL com.centurylinklabs.watchtower.enable="true"\n```\n\nOr, it can be specified as part of the `docker run` command line:\n\n```bash\ndocker run -d --label=com.centurylinklabs.watchtower.enable=true someimage\n```\n\n## Remote Hosts\n\nBy 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:\n\n```bash\ndocker run -d \\\n --name watchtower \\\n v2tec/watchtower --host "tcp://10.0.1.2:2375"\n```\n\nor\n\n```bash\ndocker run -d \\\n --name watchtower \\\n -e DOCKER_HOST="tcp://10.0.1.2:2375" \\\n v2tec/watchtower\n```\n\nNote in both of the examples above that it is unnecessary to mount the */var/run/docker.sock* into the watchtower container.\n\n### Secure Connections\n\nWatchtower 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.\n\nThe *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*.\n\nWith the certificates mounted into the watchtower container you need to specify the `--tlsverify` flag to enable verification of the certificate:\n\n```bash\ndocker run -d \\\n --name watchtower \\\n -e DOCKER_HOST=$DOCKER_HOST \\\n -v $DOCKER_CERT_PATH:/etc/ssl/docker \\\n v2tec/watchtower --tlsverify\n```\n\n## Updating Watchtower\n\nIf 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 *v2tec/watchtower* image is pushed to the Docker Hub, your watchtower will pull down the new image and restart itself automatically.\n\n## Notifications\n\nWatchtower can send notifications when containers are updated. Notifications are sent via hooks in the logging system, [logrus](http://github.com/sirupsen/logrus).\nThe types of notifications to send are passed via the comma-separated option `--notifications` (or corresponding environment variable `WATCHTOWER_NOTIFICATIONS`), which has the following valid values:\n\n* `email` to send notifications via e-mail\n* `slack` to send notifications through a Slack webhook\n\n### Settings\n\n* `--notifications-level` (env. `WATCHTOWER_NOTIFICATIONS_LEVEL`): Controls the log level which is used for the notifications. If omitted, the default log level is `info`. Possible values are: `panic`, `fatal`, `error`, `warn`, `info` or `debug`.\n\n### Notifications via E-Mail\n\nTo receive notifications by email, the following command-line options, or their corresponding environment variables, can be set:\n\n* `--notification-email-from` (env. `WATCHTOWER_NOTIFICATION_EMAIL_FROM`): The e-mail address from which notifications will be sent.\n* `--notification-email-to` (env. `WATCHTOWER_NOTIFICATION_EMAIL_TO`): The e-mail address to which notifications will be sent.\n* `--notification-email-server` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER`): The SMTP server to send e-mails through.\n* `--notification-email-server-tls-skip-verify` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_TLS_SKIP_VERIFY`): Do not verify the TLS certificate of the mail server. This should be used only for testing.\n* `--notification-email-server-port` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT`): The port used to connect to the SMTP server to send e-mails through. Defaults to `25`.\n* `--notification-email-server-user` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER`): The username to authenticate with the SMTP server with.\n* `--notification-email-server-password` (env. `WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD`): The password to authenticate with the SMTP server with.\n\nExample:\n\n```bash\ndocker run -d \\\n --name watchtower \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n -e WATCHTOWER_NOTIFICATIONS=email \\\n -e WATCHTOWER_NOTIFICATION_EMAIL_FROM=fromaddress@gmail.com \\\n -e WATCHTOWER_NOTIFICATION_EMAIL_TO=toaddress@gmail.com \\\n -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com \\\n -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=fromaddress@gmail.com \\\n -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=app_password \\\n v2tec/watchtower\n```\n\n### Notifications through Slack webhook\n\nTo receive notifications in Slack, add `slack` to the `--notifications` option or the `WATCHTOWER_NOTIFICATIONS` environment variable.\n\nAdditionally, you should set the Slack webhook url using the `--notification-slack-hook-url` option or the `WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL` environment variable.\n\nBy default, watchtower will send messages under the name `watchtower`, you can customize this string through the `--notification-slack-identifier` option or the `WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER` environment variable.\n\nExample:\n\n```bash\ndocker run -d \\\n --name watchtower \\\n -v /var/run/docker.sock:/var/run/docker.sock \\\n -e WATCHTOWER_NOTIFICATIONS=slack \\\n -e WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL="https://hooks.slack.com/services/xxx/yyyyyyyyyyyyyyy" \\\n -e WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER=watchtower-server-1 \\\n v2tec/watchtower\n```

标签

该项目暂时没有标签

版本名称 创建时间 最后更新时间
armhf-latest 2019年9月16日 15:09 2018年3月2日 23:09
armhf-0 2019年9月16日 15:09 2018年3月2日 23:09
armhf-0.3 2019年9月16日 15:09 2018年3月2日 23:09
latest 2019年9月16日 15:09 2018年3月2日 23:09
0 2019年9月16日 15:09 2018年3月2日 23:09
0.3 2019年9月16日 15:09 2018年3月2日 23:09
armhf-0.3.0 2019年9月16日 15:09 2018年3月2日 23:09
0.3.0 2019年9月16日 15:09 2018年3月2日 23:09
armhf-0.2 2019年9月16日 15:09 2018年2月28日 00:22
0.2 2019年9月16日 15:09 2018年2月28日 00:22
armhf-0.2.2 2019年9月16日 15:09 2018年2月28日 00:22
0.2.2 2019年9月16日 15:09 2018年2月28日 00:22
armhf-0.2.1 2019年9月16日 15:09 2018年1月6日 05:07
0.2.1 2019年9月16日 15:09 2018年1月6日 05:07
armhf-0.2.0 2019年9月16日 15:09 2017年12月28日 01:02
0.2.0 2019年9月16日 15:09 2017年12月28日 01:02
armhf-0.1.1 2019年9月16日 15:09 2017年6月25日 04:36
armhf-0.1 2019年9月16日 15:09 2017年6月25日 04:36
0.1.1 2019年9月16日 15:09 2017年6月25日 04:36
0.1 2019年9月16日 15:09 2017年6月25日 04:36
armhf-0.1.0 2019年9月16日 15:09 2017年3月16日 22:13
0.1.0 2019年9月16日 15:09 2017年3月16日 22:13
No Dockerfiles