Version: v1.3.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2021 License: Apache-2.0 Imports: 18 Imported by: 0




This section is empty.


This section is empty.


func ContainsWatchtowerLabel

func ContainsWatchtowerLabel(labels map[string]string) bool

ContainsWatchtowerLabel takes a map of labels and values and tells the consumer whether it contains a valid watchtower instance label

func ShortID added in v1.3.0

func ShortID(imageID string) (short string)

ShortID returns the 12-character (hex) short version of an image ID hash, removing any "sha256:" prefix if present


type Client

type Client interface {
	ListContainers(t.Filter) ([]Container, error)
	GetContainer(containerID string) (Container, error)
	StopContainer(Container, time.Duration) error
	StartContainer(Container) (string, error)
	RenameContainer(Container, string) error
	IsContainerStale(Container) (bool, error)
	ExecuteCommand(containerID string, command string, timeout int) error
	RemoveImageByID(string) error
	WarnOnHeadPullFailed(container Container) bool

A Client is the interface through which watchtower interacts with the Docker API.

func NewClient

func NewClient(pullImages, includeStopped, reviveStopped, removeVolumes, includeRestarting bool, warnOnHeadFailed string) Client

NewClient returns a new Client instance which can be used to interact with the Docker API. The client reads its configuration from the following environment variables:

* DOCKER_HOST			the docker-engine host to send api requests to
* DOCKER_TLS_VERIFY		whether to verify tls certificates
* DOCKER_API_VERSION	the minimum docker api version to work with

type Container

type Container struct {
	LinkedToRestarting bool
	Stale              bool
	// contains filtered or unexported fields

Container represents a running Docker container.

func NewContainer

func NewContainer(containerInfo *types.ContainerJSON, imageInfo *types.ImageInspect) *Container

NewContainer returns a new Container instance instantiated with the specified ContainerInfo and ImageInfo structs.

func (Container) ContainerInfo added in v0.3.11

func (c Container) ContainerInfo() *types.ContainerJSON

ContainerInfo fetches JSON info for the container

func (Container) Enabled

func (c Container) Enabled() (bool, bool)

Enabled returns the value of the container enabled label and if the label was set.

func (Container) GetLifecyclePostCheckCommand added in v0.3.10

func (c Container) GetLifecyclePostCheckCommand() string

GetLifecyclePostCheckCommand returns the post-check command set in the container metadata or an empty string

func (Container) GetLifecyclePostUpdateCommand

func (c Container) GetLifecyclePostUpdateCommand() string

GetLifecyclePostUpdateCommand returns the post-update command set in the container metadata or an empty string

func (Container) GetLifecyclePreCheckCommand added in v0.3.10

func (c Container) GetLifecyclePreCheckCommand() string

GetLifecyclePreCheckCommand returns the pre-check command set in the container metadata or an empty string

func (Container) GetLifecyclePreUpdateCommand

func (c Container) GetLifecyclePreUpdateCommand() string

GetLifecyclePreUpdateCommand returns the pre-update command set in the container metadata or an empty string

func (Container) HasImageInfo added in v1.0.3

func (c Container) HasImageInfo() bool

HasImageInfo returns whether image information could be retrieved for the container

func (Container) ID

func (c Container) ID() string

ID returns the Docker container ID.

func (Container) ImageID

func (c Container) ImageID() string

ImageID returns the ID of the Docker image that was used to start the container.

func (Container) ImageInfo added in v1.1.0

func (c Container) ImageInfo() *types.ImageInspect

ImageInfo fetches the ImageInspect data of the current container

func (Container) ImageName

func (c Container) ImageName() string

ImageName returns the name of the Docker image that was used to start the container. If the original image was specified without a particular tag, the "latest" tag is assumed.

func (Container) IsMonitorOnly added in v1.0.3

func (c Container) IsMonitorOnly() bool

IsMonitorOnly returns the value of the monitor-only label. If the label is not set then false is returned.

func (Container) IsRunning

func (c Container) IsRunning() bool

IsRunning returns a boolean flag indicating whether or not the current container is running. The status is determined by the value of the container's "State.Running" property.

func (Container) IsWatchtower

func (c Container) IsWatchtower() bool

IsWatchtower returns a boolean flag indicating whether or not the current container is the watchtower container itself. The watchtower container is identified by the presence of the "com.centurylinklabs.watchtower" label in the container metadata.

func (c Container) Links() []string

Links returns a list containing the names of all the containers to which this container is linked.

func (Container) Name

func (c Container) Name() string

Name returns the Docker container name.

func (Container) PreUpdateTimeout added in v1.0.0

func (c Container) PreUpdateTimeout() int

PreUpdateTimeout checks whether a container has a specific timeout set for how long the pre-update command is allowed to run. This value is expressed either as an integer, in minutes, or as 0 which will allow the command/script to run indefinitely. Users should be cautious with the 0 option, as that could result in watchtower waiting forever.

func (Container) Scope added in v1.0.3

func (c Container) Scope() (string, bool)

Scope returns the value of the scope UID label and if the label was set.

func (Container) StopSignal

func (c Container) StopSignal() string

StopSignal returns the custom stop signal (if any) that is encoded in the container's metadata. If the container has not specified a custom stop signal, the empty string "" is returned.

func (Container) ToRestart

func (c Container) ToRestart() bool

ToRestart return whether the container should be restarted, either because is stale or linked to another stale container.

func (Container) VerifyConfiguration added in v1.3.0

func (c Container) VerifyConfiguration() error

VerifyConfiguration checks the container and image configurations for nil references to make sure that the container can be recreated once deleted


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL