Documentation
¶
Index ¶
- type Client
- type ClientOptions
- type Container
- func (c Container) GetLabel(key string) string
- func (c Container) GetScope() string
- func (c Container) GetStopSignal() string
- func (c Container) GetStopTimeout(defaultTimeout time.Duration) time.Duration
- func (c Container) HasLabel(key string) bool
- func (c Container) IsEnabled(labelName string, defaultEnabled bool) bool
- func (c Container) IsHealthy() bool
- func (c Container) IsPaused() bool
- func (c Container) IsRestarting() bool
- func (c Container) IsRunning() bool
- func (c Container) IsUnhealthy() bool
- func (c Container) UpdateEnabled() bool
- func (c Container) WatchEnabled() bool
- type ListOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Ping() error
ListContainers(ctx context.Context, opts ListOptions) ([]Container, error)
GetContainer(ctx context.Context, id string) (Container, error)
StopContainer(ctx context.Context, id string, timeout time.Duration, signal string) error
StartContainer(ctx context.Context, id string) error
RestartContainer(ctx context.Context, id string, timeout time.Duration, signal string) error
RemoveContainer(ctx context.Context, id string) error
RenameContainer(ctx context.Context, id string, newName string) error
RecreateContainer(ctx context.Context, id string, timeout time.Duration, startStopped bool) (string, error)
PullImage(ctx context.Context, imageName string) error
GetImageDigest(ctx context.Context, imageName string) (string, error)
GetImageID(ctx context.Context, imageName string) (string, error)
RemoveImage(ctx context.Context, imageID string) error
ContainerLogs(ctx context.Context, id string, follow bool, tail string) (io.ReadCloser, error)
CloneContainer(ctx context.Context, id string, newName string) (string, error)
GetSelfContainerID() string
GetContainerBinds(ctx context.Context, id string) ([]string, error)
CreateHelperContainer(ctx context.Context, image string, cmd []string, binds []string) (string, error)
}
Client interface for Docker operations
func NewClient ¶
func NewClient(opts ClientOptions) (Client, error)
NewClient creates a new Docker client
type ClientOptions ¶
ClientOptions configures the Docker client
type Container ¶
type Container struct {
ID string
Name string
Image string
ImageID string
State string
Status string
Labels map[string]string
Created time.Time
HealthStatus string
// Filled only by GetContainer (inspect); a list summary leaves them zero.
RestartPolicy string // HostConfig.RestartPolicy.Name: "", "no", "always", "unless-stopped", "on-failure"
ExitCode int // State.ExitCode of the last run
OOMKilled bool // State.OOMKilled of the last run
}
Container represents a Docker container
func (Container) GetStopSignal ¶
GetStopSignal returns the stop signal from the dockwarden.stop-signal label, or "" when unset. Empty means "let the daemon decide", which honours the container's own STOPSIGNAL (from the image or create config) — returning a hardcoded SIGTERM here would override images like nginx that declare SIGQUIT.
func (Container) GetStopTimeout ¶
GetStopTimeout returns the configured stop timeout or default.
The documented label form is a bare number of seconds ("60"), but a Go duration ("30s", "1m") is also accepted. The bare form must be tried first: naively appending "s" turned "1m" into "1ms" — a one-millisecond grace period before SIGKILL — and turned "30s" into the unparseable "30ss", silently discarding the label.
func (Container) IsEnabled ¶
IsEnabled returns true if the container should be managed by DockWarden
func (Container) IsRestarting ¶ added in v1.3.0
IsRestarting returns true if the container is in the restarting state
func (Container) IsUnhealthy ¶
IsUnhealthy returns true if the container is unhealthy
func (Container) UpdateEnabled ¶
UpdateEnabled returns true if updates are enabled for this container
func (Container) WatchEnabled ¶
WatchEnabled returns true if health watching is enabled for this container
type ListOptions ¶
ListOptions for filtering containers