mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-14 14:10:12 +01:00
Add auth config, registry auth fails silently without
This commit is contained in:
parent
44dbd88295
commit
ef430b791a
2 changed files with 15 additions and 6 deletions
|
|
@ -45,7 +45,7 @@ func Update(client container.Client, names []string, cleanup bool) error {
|
||||||
for i, container := range containers {
|
for i, container := range containers {
|
||||||
stale, err := client.IsContainerStale(container)
|
stale, err := client.IsContainerStale(container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Infof("Unable to update container %. Proceeding to next.", containers[i].Name())
|
log.Infof("Unable to update container %s. Proceeding to next.", containers[i].Name())
|
||||||
log.Debug(err)
|
log.Debug(err)
|
||||||
stale = false
|
stale = false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
dockerclient "github.com/docker/docker/client"
|
dockerclient "github.com/docker/docker/client"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
"github.com/docker/docker/cli/command"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -145,15 +146,22 @@ 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())
|
||||||
|
|
||||||
// Note: ImagePullOptions below can take a RegistryAuth arg if 401 on private registry
|
auth := types.AuthConfig {
|
||||||
closer, err := client.api.ImagePull(bg, imageName, types.ImagePullOptions{})
|
Username: "testuser",
|
||||||
if (err != nil) {
|
Password: "testpassword",
|
||||||
log.Debugf("Error pulling image %s, %s", imageName, err)
|
}
|
||||||
|
encodedAuth, err := command.EncodeAuthToBase64(auth)
|
||||||
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else {
|
|
||||||
closer.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: ImagePullOptions below can take a RegistryAuth arg if 401 on private registry
|
||||||
|
closer, err := client.api.ImagePull(bg, imageName, types.ImagePullOptions{RegistryAuth: encodedAuth})
|
||||||
|
if err != nil {
|
||||||
|
log.Debugf("Error pulling image %s, %s", imageName, err)
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
defer closer.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
newImageInfo, _, err := client.api.ImageInspectWithRaw(bg, imageName)
|
newImageInfo, _, err := client.api.ImageInspectWithRaw(bg, imageName)
|
||||||
|
|
@ -166,6 +174,7 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
} else {
|
} else {
|
||||||
log.Debugf("No new images found for %s", c.Name())
|
log.Debugf("No new images found for %s", c.Name())
|
||||||
|
log.Debugf("Old image ID %s is the same as New Image ID %s", oldImageInfo.ID, newImageInfo.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue