You've already forked watchtower
mirror of
https://github.com/containrrr/watchtower.git
synced 2025-07-12 23:50:20 +02:00
@ -1,6 +1,4 @@
|
|||||||
FROM centurylink/ca-certs
|
FROM ubuntu:14.04
|
||||||
MAINTAINER CenturyLink Labs <innovationslab@ctl.io>
|
|
||||||
LABEL "com.centurylinklabs.watchtower"="true"
|
|
||||||
|
|
||||||
COPY watchtower /
|
COPY watchtower /
|
||||||
ENTRYPOINT ["/watchtower"]
|
ENTRYPOINT ["/watchtower"]
|
||||||
|
10
README.md
10
README.md
@ -39,6 +39,16 @@ docker run -d \
|
|||||||
centurylink/watchtower
|
centurylink/watchtower
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For private images:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -d \
|
||||||
|
--name watchtower \
|
||||||
|
-e REPO_USER="username" -e REPO_PASS="pass" -e REPO_EMAIL="email" \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
drud/watchtower container_to_watch --debug
|
||||||
|
```
|
||||||
|
|
||||||
### Arguments
|
### 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 launching watchtower.
|
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 launching watchtower.
|
||||||
|
@ -3,6 +3,7 @@ package container
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
@ -13,6 +14,10 @@ const (
|
|||||||
defaultStopSignal = "SIGTERM"
|
defaultStopSignal = "SIGTERM"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var username = os.Getenv("REPO_USER")
|
||||||
|
var password = os.Getenv("REPO_PASS")
|
||||||
|
var email = os.Getenv("REPO_EMAIL")
|
||||||
|
|
||||||
// A Filter is a prototype for a function that can be used to filter the
|
// A Filter is a prototype for a function that can be used to filter the
|
||||||
// results from a call to the ListContainers() method on the Client.
|
// results from a call to the ListContainers() method on the Client.
|
||||||
type Filter func(Container) bool
|
type Filter func(Container) bool
|
||||||
@ -111,7 +116,19 @@ func (client dockerClient) StartContainer(c Container) error {
|
|||||||
|
|
||||||
log.Infof("Starting %s", name)
|
log.Infof("Starting %s", name)
|
||||||
|
|
||||||
newContainerID, err := client.api.CreateContainer(config, name)
|
var err error
|
||||||
|
var newContainerID string
|
||||||
|
if username != "" && password != "" && email != "" {
|
||||||
|
auth := dockerclient.AuthConfig{
|
||||||
|
Username: username,
|
||||||
|
Password: password,
|
||||||
|
Email: email,
|
||||||
|
}
|
||||||
|
newContainerID, err = client.api.CreateContainer(config, name, &auth)
|
||||||
|
} else {
|
||||||
|
newContainerID, err = client.api.CreateContainer(config, name, nil)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -132,11 +149,24 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
|
|||||||
|
|
||||||
if client.pullImages {
|
if client.pullImages {
|
||||||
log.Debugf("Pulling %s for %s", imageName, c.Name())
|
log.Debugf("Pulling %s for %s", imageName, c.Name())
|
||||||
|
|
||||||
|
if username != "" && password != "" && email != "" {
|
||||||
|
auth := dockerclient.AuthConfig{
|
||||||
|
Username: username,
|
||||||
|
Password: password,
|
||||||
|
Email: email,
|
||||||
|
}
|
||||||
|
if err := client.api.PullImage(imageName, &auth); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if err := client.api.PullImage(imageName, nil); err != nil {
|
if err := client.api.PullImage(imageName, nil); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
newImageInfo, err := client.api.InspectImage(imageName)
|
newImageInfo, err := client.api.InspectImage(imageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -153,7 +183,7 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
|
|||||||
func (client dockerClient) RemoveImage(c Container) error {
|
func (client dockerClient) RemoveImage(c Container) error {
|
||||||
imageID := c.ImageID()
|
imageID := c.ImageID()
|
||||||
log.Infof("Removing image %s", imageID)
|
log.Infof("Removing image %s", imageID)
|
||||||
_, err := client.api.RemoveImage(imageID)
|
_, err := client.api.RemoveImage(imageID, true)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user