Documentation
¶
Overview ¶
credit: https://github.com/containrrr/watchtower
credit: https://github.com/containrrr/watchtower
credit: https://github.com/containrrr/watchtower
credit: https://github.com/containrrr/watchtower
credit: https://github.com/containrrr/watchtower
credit: https://github.com/containrrr/watchtower
Index ¶
- Constants
- Variables
- func BuildManifestURL(imageName string) (string, error)
- func CPUPercent(s *types.StatsJSON) float64
- func CloneContainer(ctx context.Context, id string, newName string) (string, error)
- func CompareDigest(imageName string, repoDigests []string) (bool, error)
- func Container(ctx context.Context, id string) (*types.ContainerJSON, error)
- func ContainsDigest(repoDigests []string, digest string) bool
- func ConvertToHostname(url string) (string, string, error)
- func CredentialsStore(configFile configfile.ConfigFile) credentials.Store
- func CurrentArchitecture() (string, error)
- func EncodeAuth(authConfig types.AuthConfig) (string, error)
- func EncodedAuth(ref string) (string, error)
- func EncodedConfigAuth(ref string) (string, error)
- func EncodedEnvAuth(ref string) (string, error)
- func ExtractImageAndTag(imageName string) (string, string)
- func GetArchitectures(imageName string, noCache bool) ([]string, error)
- func GetAuthURL(challenge string, img string) (*url.URL, error)
- func GetBearerHeader(challenge string, img string, registryAuth string) (string, error)
- func GetChallenge(imageName string) (string, error)
- func GetChallengeRequest(URL url.URL) (*http.Request, error)
- func GetChallengeURL(img string) (url.URL, error)
- func GetDigest(url string, token string) (string, error)
- func GetDir(id, envName string) string
- func GetManifest(ctx context.Context, imageName string) (interface{}, string, error)
- func GetPullOptions(imageName string) (image.PullOptions, error)
- func GetScopeFromImageName(img, svc string) string
- func GetToken(challenge string, registryAuth string, imageName string) (string, error)
- func HasNewImage(ctx context.Context, imageName string, currentImageID string) (bool, string, error)
- func Image(ctx context.Context, imageName string) (*types.ImageInspect, error)
- func ImageName(containerInfo *types.ContainerJSON) string
- func IsDaemonRunning() bool
- func MemoryUsage(s *types.StatsJSON) (used uint64, limit uint64)
- func NormalizeRegistry(registry string) (string, error)
- func ParseServerAddress(ref string) (string, error)
- func PullImage(ctx context.Context, imageName string, handleOut func(io.ReadCloser)) error
- func RegistryDigest(imageName string) (string, error)
- func RemoveContainer(ctx context.Context, id string) error
- func RenameContainer(ctx context.Context, id string, name string) error
- func RestartContainer(ctx context.Context, id string) error
- func SampleContainerStats(ctx context.Context, cli *client.Client, id string) (*types.StatsJSON, error)
- func StartContainer(ctx context.Context, id string) error
- func StopContainer(ctx context.Context, id string) error
- func TransformAuth(registryAuth string) string
- func VolumeMountpoint(ctx context.Context, cli *client.Client, name string) (string, error)
- func VolumeUsage(ctx context.Context, cli *client.Client) (map[string]VolumeSpace, error)
- func WaitContainer(ctx context.Context, id string, condition container.WaitCondition) error
- type RegistryCredentials
- type TokenResponse
- type VolumeSpace
Constants ¶
const ChallengeHeader = "WWW-Authenticate"
ChallengeHeader is the HTTP Header containing challenge instructions
const ContentDigestHeader = "Docker-Content-Digest"
ContentDigestHeader is the key for the key-value pair containing the digest header
const NETWORKNAME = "oasis"
Variables ¶
var Cache *cache.Cache
Functions ¶
func BuildManifestURL ¶
BuildManifestURL from raw image data
func CPUPercent ¶ added in v0.4.37
CPUPercent is how busy a container has been BETWEEN two samples, which is why a single sample cannot answer it: CPU usage is a counter that only goes up, so a lone reading says how much CPU the container has used since it started, not how much it is using now.
Docker ships the previous sample inside the current one, so the arithmetic is the same as `docker stats`: the container's own delta over the machine's, times the number of CPUs it could have been running on. A container pinned at 100% of two cores reads 200, like the CLI, rather than 100.
Zero when the deltas make no sense -- the first frame of a stream carries an empty previous sample, and a container that stopped between samples goes backwards.
func CloneContainer ¶
func CompareDigest ¶
CompareDigest ...
func ContainsDigest ¶
ContainsDigest reports whether a local image's RepoDigests include one digest. RepoDigests read `repo@sha256:...`; an entry without the `@` is not one and is skipped rather than indexed into.
func ConvertToHostname ¶
ConvertToHostname strips a url from everything but the hostname part
func CredentialsStore ¶
func CredentialsStore(configFile configfile.ConfigFile) credentials.Store
CredentialsStore returns a new credentials store based on the settings provided in the configuration file.
func CurrentArchitecture ¶
func EncodeAuth ¶
func EncodeAuth(authConfig types.AuthConfig) (string, error)
EncodeAuth Base64 encode an AuthConfig struct for transmission over HTTP
func EncodedAuth ¶
EncodedAuth returns an encoded auth config for the given registry loaded from environment variables or docker config as available in that order
func EncodedConfigAuth ¶
EncodedConfigAuth returns an encoded auth config for the given registry loaded from the docker config Returns an empty string if credentials cannot be found for the referenced server The docker config must be mounted on the container
func EncodedEnvAuth ¶
EncodedEnvAuth returns an encoded auth config for the given registry loaded from environment variables Returns an error if authentication environment variables have not been set
func ExtractImageAndTag ¶
ExtractImageAndTag splits a reference into the image and its tag.
The colon that separates a tag is the last one AFTER the last slash. A registry carries a port before the first slash -- `registry:5000/img:2.0` -- and splitting on the first colon returned `registry` and `5000/img:2.0`. That string is not a version, so the update check treated every such app as unorderable and offered it whatever the catalogue held, in either direction.
A reference pinned by digest has no tag at all, and comes back whole with an empty tag rather than split at the digest's own colon.
func GetAuthURL ¶
GetAuthURL from the instructions in the challenge
func GetBearerHeader ¶
GetBearerHeader tries to fetch a bearer token from the registry based on the challenge instructions
func GetChallenge ¶
GetChallenge fetches a challenge for the registry hosting the provided image
func GetChallengeRequest ¶
GetChallengeRequest creates a request for getting challenge instructions
func GetChallengeURL ¶
GetChallengeURL creates a URL object based on the image info
func GetManifest ¶
func GetPullOptions ¶
func GetPullOptions(imageName string) (image.PullOptions, error)
GetPullOptions creates a struct with all options needed for pulling images from a registry
func GetScopeFromImageName ¶
GetScopeFromImageName normalizes an image name for use as scope during auth and head requests
func HasNewImage ¶
func ImageName ¶
func ImageName(containerInfo *types.ContainerJSON) string
func IsDaemonRunning ¶
func IsDaemonRunning() bool
func MemoryUsage ¶ added in v0.4.37
MemoryUsage is what the container actually holds, and its ceiling.
Docker's raw `usage` counts the page cache, which makes a container that has merely read a large file look like it is holding it. Both the CLI and every dashboard worth trusting subtract that: `inactive_file` under cgroup v2, and `total_inactive_file` under v1. Neither key is present on Windows, where the raw value is already the working set.
The limit is the host's whole memory when the container declares none, which is Docker's own answer and is what makes the percentage meaningful.
func NormalizeRegistry ¶
NormalizeRegistry makes sure variations of DockerHubs registry
func ParseServerAddress ¶
ParseServerAddress extracts the server part from a container image ref
func RegistryDigest ¶
RegistryDigest is the digest the registry publishes for an image reference right now.
Exposed on its own because a caller holding several local digests -- one per running container of a service, say -- has to compare each of them against the registry, and a yes/no about one set of digests cannot say which of them matched.
func RestartContainer ¶ added in v0.4.37
RestartContainer restarts a container, and leaves it running whether or not it was before. Docker's own restart is one call: stop-then-start from here would race anything that reads the container in between, and would have to reinvent the stop timeout the daemon already applies.
func SampleContainerStats ¶ added in v0.4.37
func SampleContainerStats(ctx context.Context, cli *client.Client, id string) (*types.StatsJSON, error)
SampleContainerStats reads a container's usage.
It takes TWO frames off the stream rather than asking for one, because one is not enough: the one-shot endpoint returns an empty previous sample, so CPU cannot be computed from it at all. The daemon emits roughly once a second, so this call lasts about that long and the caller's context is what bounds it.
func TransformAuth ¶
TransformAuth from a base64 encoded json object to base64 encoded string
func VolumeMountpoint ¶ added in v0.4.37
VolumeMountpoint is where the daemon keeps a named volume on this host.
Asked rather than worked out. The path looks predictable -- /var/lib/docker/volumes/<name>/_data -- right up until the daemon has a data-root of its own, or the volume has a driver that puts it somewhere else entirely. A backup that copies from a path nobody confirmed can find an empty folder and report success.
An empty answer means the daemon does not know this volume.
func VolumeUsage ¶ added in v0.4.38
VolumeUsage is how much room each named volume takes and how many containers reference it.
One call for every volume on the host rather than one per volume: the daemon computes this by walking the filesystem, and asking it repeatedly for the same answer is how a panel that lists four volumes takes ten seconds to open.
A driver that cannot measure a volume reports -1 for the size, and a daemon that cannot count references reports -1 for the count. Both are passed through as they are: "not available" is an answer, and turning it into 0 would read as an empty volume nothing uses, which is exactly the thing somebody would then delete.
func WaitContainer ¶
Types ¶
type RegistryCredentials ¶
type RegistryCredentials struct {
Username string
Password string // usually a token rather than an actual password
}
RegistryCredentials is a credential pair used for basic auth
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
}
type VolumeSpace ¶ added in v0.4.38
type VolumeSpace struct {
// Size in bytes, or -1 when the driver cannot measure it.
Size int64
// Containers referencing it, or -1 when the daemon cannot say.
Containers int64
}
VolumeSpace is what the daemon can say about a volume's size and use.