mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
Add label definitions that allow containers to override image name and id
This commit is contained in:
parent
76f9cea516
commit
85ea00f3ad
3 changed files with 9 additions and 1 deletions
|
@ -332,6 +332,12 @@ func (client dockerClient) HasNewImage(ctx context.Context, container t.Containe
|
|||
currentImageID := t.ImageID(container.ContainerInfo().ContainerJSONBase.Image)
|
||||
imageName := container.ImageName()
|
||||
|
||||
imageIDSetByLabel, ok := container.ContainerInfo().Config.Labels[originalImageIDLabel]
|
||||
if ok {
|
||||
currentImageID = t.ImageID(imageIDSetByLabel)
|
||||
log.Infof("Original image id for %s found: (%s)", imageName, currentImageID.ShortID())
|
||||
}
|
||||
|
||||
newImageInfo, _, err := client.api.ImageInspectWithRaw(ctx, imageName)
|
||||
if err != nil {
|
||||
return false, currentImageID, err
|
||||
|
|
|
@ -103,7 +103,7 @@ func (c Container) SafeImageID() wt.ImageID {
|
|||
// "latest" tag is assumed.
|
||||
func (c Container) ImageName() string {
|
||||
// Compatibility w/ Zodiac deployments
|
||||
imageName, ok := c.getLabelValue(zodiacLabel)
|
||||
imageName, ok := c.getLabelValue(originalImageNameLabel)
|
||||
if !ok {
|
||||
imageName = c.containerInfo.Config.Image
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ const (
|
|||
noPullLabel = "com.centurylinklabs.watchtower.no-pull"
|
||||
dependsOnLabel = "com.centurylinklabs.watchtower.depends-on"
|
||||
zodiacLabel = "com.centurylinklabs.zodiac.original-image"
|
||||
originalImageNameLabel = "com.centurylinklabs.watchtower.original-image"
|
||||
originalImageIDLabel = "com.centurylinklabs.watchtower.original-image-id"
|
||||
scope = "com.centurylinklabs.watchtower.scope"
|
||||
preCheckLabel = "com.centurylinklabs.watchtower.lifecycle.pre-check"
|
||||
postCheckLabel = "com.centurylinklabs.watchtower.lifecycle.post-check"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue