mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 15:10:12 +01:00
ft: allow detect changes local images
This commit is contained in:
parent
36391b0ae7
commit
1f8e22ed91
4 changed files with 22 additions and 0 deletions
|
|
@ -311,6 +311,10 @@ func (client dockerClient) RenameContainer(c t.Container, newName string) error
|
|||
func (client dockerClient) IsContainerStale(container t.Container) (stale bool, latestImage t.ImageID, err error) {
|
||||
ctx := context.Background()
|
||||
|
||||
if isLocalImage, checkErr := container.LocalImage(); checkErr && isLocalImage {
|
||||
return client.HasNewImage(ctx, container)
|
||||
}
|
||||
|
||||
if !client.PullImages || container.IsNoPull() {
|
||||
log.Debugf("Skipping image pull.")
|
||||
} else if err := client.PullImage(ctx, container); err != nil {
|
||||
|
|
|
|||
|
|
@ -113,6 +113,22 @@ func (c Container) ImageName() string {
|
|||
return imageName
|
||||
}
|
||||
|
||||
// Local returns the value of the container local label and if the label
|
||||
// was set.
|
||||
func (c Container) LocalImage() (bool, bool) {
|
||||
rawBool, ok := c.getLabelValue(enableLocal)
|
||||
if !ok {
|
||||
return false, false
|
||||
}
|
||||
|
||||
parsedBool, err := strconv.ParseBool(rawBool)
|
||||
if err != nil {
|
||||
return false, false
|
||||
}
|
||||
|
||||
return parsedBool, true
|
||||
}
|
||||
|
||||
// Enabled returns the value of the container enabled label and if the label
|
||||
// was set.
|
||||
func (c Container) Enabled() (bool, bool) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const (
|
|||
watchtowerLabel = "com.centurylinklabs.watchtower"
|
||||
signalLabel = "com.centurylinklabs.watchtower.stop-signal"
|
||||
enableLabel = "com.centurylinklabs.watchtower.enable"
|
||||
enableLocal = "com.centurylinklabs.watchtower.local-image"
|
||||
monitorOnlyLabel = "com.centurylinklabs.watchtower.monitor-only"
|
||||
noPullLabel = "com.centurylinklabs.watchtower.no-pull"
|
||||
dependsOnLabel = "com.centurylinklabs.watchtower.depends-on"
|
||||
|
|
|
|||
|
|
@ -75,4 +75,5 @@ type Container interface {
|
|||
IsRestarting() bool
|
||||
GetCreateConfig() *dc.Config
|
||||
GetCreateHostConfig() *dc.HostConfig
|
||||
LocalImage() (bool, bool)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue