Help us shape the future of Go! Take the 2026 Go Developer Survey

container

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: BSD-3-Clause Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionResult

type ActionResult struct {
	// Started is a list of container IDs that were started.
	//
	// Required: false
	Started []string `json:"started,omitempty"`

	// Stopped is a list of container IDs that were stopped.
	//
	// Required: false
	Stopped []string `json:"stopped,omitempty"`

	// Failed is a list of container IDs that failed.
	//
	// Required: false
	Failed []string `json:"failed,omitempty"`

	// Success indicates if the overall action was successful.
	//
	// Required: true
	Success bool `json:"success"`

	// Errors is a list of error messages encountered.
	//
	// Required: false
	Errors []string `json:"errors,omitempty"`
}

ActionResult represents the result of a container action (start/stop/etc).

type ComposeInfo added in v1.17.0

type ComposeInfo struct {
	// ProjectName is the name of the Docker Compose project.
	//
	// Required: true
	ProjectName string `json:"projectName"`

	// ServiceName is the name of the service within the Compose project.
	//
	// Required: true
	ServiceName string `json:"serviceName"`

	// WorkingDir is the working directory of the Compose project.
	//
	// Required: false
	WorkingDir string `json:"workingDir,omitempty"`

	// ConfigFiles is the list of Compose config file paths for the project.
	//
	// Required: false
	ConfigFiles string `json:"configFiles,omitempty"`
}

ComposeInfo contains Docker Compose project information extracted from container labels.

type Config

type Config struct {
	// Env is a list of environment variables.
	//
	// Required: false
	Env []string `json:"env,omitempty"`

	// Cmd is the command to run.
	//
	// Required: false
	Cmd []string `json:"cmd,omitempty"`

	// Entrypoint is the entrypoint for the container.
	//
	// Required: false
	Entrypoint []string `json:"entrypoint,omitempty"`

	// WorkingDir is the working directory.
	//
	// Required: false
	WorkingDir string `json:"workingDir,omitempty"`

	// User to run as.
	//
	// Required: false
	User string `json:"user,omitempty"`

	// Healthcheck is the container's healthcheck configuration.
	//
	// Required: false
	Healthcheck *Healthcheck `json:"healthcheck,omitempty"`
}

Config represents configuration details for a container.

type Create

type Create struct {
	// Name of the container.
	//
	// Required: true
	Name string `json:"name" binding:"required"`

	// Image to use for the container.
	//
	// Required: true
	Image string `json:"image" binding:"required"`

	// Command to run in the container.
	//
	// Required: false
	Command []string `json:"command,omitempty"`

	// Cmd is an alias for Command.
	//
	// Required: false
	Cmd []string `json:"cmd,omitempty"`

	// Entrypoint for the container.
	//
	// Required: false
	Entrypoint []string `json:"entrypoint,omitempty"`

	// WorkingDir is the working directory inside the container.
	//
	// Required: false
	WorkingDir string `json:"workingDir,omitempty"`

	// User to run the container as.
	//
	// Required: false
	User string `json:"user,omitempty"`

	// Environment variables for the container.
	//
	// Required: false
	Environment []string `json:"environment,omitempty"`

	// Env is an alias for Environment.
	//
	// Required: false
	Env []string `json:"env,omitempty"`

	// Labels to set on the container.
	//
	// Required: false
	Labels map[string]string `json:"labels,omitempty"`

	// ExposedPorts are ports exposed by the container.
	//
	// Required: false
	ExposedPorts map[string]struct{} `json:"exposedPorts,omitempty"`

	// HostConfig holds advanced host-level settings.
	//
	// Required: false
	HostConfig *HostConfigCreate `json:"hostConfig,omitempty"`

	// NetworkingConfig defines network endpoints.
	//
	// Required: false
	NetworkingConfig *NetworkingConfigCreate `json:"networkingConfig,omitempty"`

	// Hostname for the container.
	//
	// Required: false
	Hostname string `json:"hostname,omitempty"`

	// Domainname for the container.
	//
	// Required: false
	Domainname string `json:"domainname,omitempty"`

	// AttachStdout attaches stdout.
	//
	// Required: false
	AttachStdout bool `json:"attachStdout,omitempty"`

	// AttachStderr attaches stderr.
	//
	// Required: false
	AttachStderr bool `json:"attachStderr,omitempty"`

	// AttachStdin attaches stdin.
	//
	// Required: false
	AttachStdin bool `json:"attachStdin,omitempty"`

	// Tty allocates a pseudo-TTY.
	//
	// Required: false
	Tty bool `json:"tty,omitempty"`

	// OpenStdin keeps stdin open.
	//
	// Required: false
	OpenStdin bool `json:"openStdin,omitempty"`

	// StdinOnce closes stdin after first attach.
	//
	// Required: false
	StdinOnce bool `json:"stdinOnce,omitempty"`

	// NetworkDisabled disables networking.
	//
	// Required: false
	NetworkDisabled bool `json:"networkDisabled,omitempty"`

	// Ports is a map of port bindings.
	//
	// Required: false
	Ports map[string]string `json:"ports,omitempty"`

	// Volumes is a list of volume mounts.
	//
	// Required: false
	Volumes []string `json:"volumes,omitempty"`

	// Networks is a list of networks to connect to.
	//
	// Required: false
	Networks []string `json:"networks,omitempty"`

	// RestartPolicy for the container.
	//
	// Required: false
	RestartPolicy string `json:"restartPolicy,omitempty"`

	// Privileged indicates if the container runs in privileged mode.
	//
	// Required: false
	Privileged bool `json:"privileged,omitempty"`

	// AutoRemove indicates if the container should be removed when stopped.
	//
	// Required: false
	AutoRemove bool `json:"autoRemove,omitempty"`

	// Memory limit for the container in bytes.
	//
	// Required: false
	Memory int64 `json:"memory,omitempty"`

	// CPUs is the number of CPUs to allocate.
	//
	// Required: false
	CPUs float64 `json:"cpus,omitempty"`

	// Credentials for pulling images from private registries.
	//
	// Required: false
	Credentials []containerregistry.Credential `json:"credentials,omitempty"`
}

Create is used to create a new container.

type Created

type Created struct {
	// ID is the unique identifier of the container.
	//
	// Required: true
	ID string `json:"id"`

	// Name of the container.
	//
	// Required: true
	Name string `json:"name"`

	// Image used by the container.
	//
	// Required: true
	Image string `json:"image"`

	// Status of the container.
	//
	// Required: true
	Status string `json:"status"`

	// Created is when the container was created.
	//
	// Required: true
	Created string `json:"created"`
}

Created represents a newly created container.

type Details

type Details struct {
	// ID is the unique identifier of the container.
	//
	// Required: true
	ID string `json:"id"`

	// Name of the container.
	//
	// Required: true
	Name string `json:"name"`

	// Image used by the container.
	//
	// Required: true
	Image string `json:"image"`

	// ImageID is the ID of the image.
	//
	// Required: true
	ImageID string `json:"imageId"`

	// Created is when the container was created.
	//
	// Required: true
	Created string `json:"created"`

	// State contains the container's current state.
	//
	// Required: true
	State State `json:"state"`

	// Config contains container configuration.
	//
	// Required: true
	Config Config `json:"config"`

	// HostConfig contains host-level configuration.
	//
	// Required: true
	HostConfig HostConfig `json:"hostConfig"`

	// NetworkSettings contains network configuration.
	//
	// Required: true
	NetworkSettings NetworkSettings `json:"networkSettings"`

	// Ports exposed by the container.
	//
	// Required: true
	Ports []Port `json:"ports"`

	// Mounts lists volume mounts.
	//
	// Required: true
	Mounts []Mount `json:"mounts"`

	// Labels contains user-defined metadata.
	//
	// Required: false
	Labels map[string]string `json:"labels,omitempty"`

	// ComposeInfo contains Docker Compose project information.
	// Only present if container is part of a Compose project.
	//
	// Required: false
	ComposeInfo *ComposeInfo `json:"composeInfo,omitempty"`

	// RedeployDisabled indicates whether redeploy actions are disabled for this container.
	//
	// Required: false
	RedeployDisabled bool `json:"redeployDisabled,omitempty"`
}

Details represents detailed container information.

func NewDetails

func NewDetails(c *container.InspectResponse) Details

NewDetails creates a Details from a docker container.InspectResponse.

type EndpointSettingsCreate

type EndpointSettingsCreate struct {
	// Aliases for the container on this network.
	//
	// Required: false
	Aliases []string `json:"aliases,omitempty"`
}

EndpointSettingsCreate represents network endpoint settings for container creation.

type Health added in v1.18.0

type Health struct {
	// Status is the current healthcheck status (starting, healthy, unhealthy, none).
	//
	// Required: true
	Status string `json:"status"`

	// FailingStreak is the number of consecutive failures.
	//
	// Required: false
	FailingStreak int `json:"failingStreak"`

	// Log is the recent probe history, oldest first.
	//
	// Required: false
	Log []HealthLogEntry `json:"log,omitempty"`
}

Health represents the current healthcheck state of a container.

type HealthLogEntry added in v1.18.0

type HealthLogEntry struct {
	// Start is when the probe started.
	//
	// Required: false
	Start string `json:"start,omitempty"`

	// End is when the probe finished.
	//
	// Required: false
	End string `json:"end,omitempty"`

	// ExitCode is the exit code of the probe command.
	//
	// Required: false
	ExitCode int `json:"exitCode"`

	// Output is the stdout/stderr captured from the probe.
	//
	// Required: false
	Output string `json:"output,omitempty"`
}

HealthLogEntry represents a single probe result from the healthcheck log.

type Healthcheck added in v1.18.0

type Healthcheck struct {
	// Test is the probe command. Common forms:
	//  - empty / nil: inherit from the image
	//  - ["NONE"]: healthcheck disabled
	//  - ["CMD", "..."] / ["CMD-SHELL", "..."]: probe command
	//
	// Required: false
	Test []string `json:"test,omitempty"`

	// Interval between probes, in nanoseconds.
	//
	// Required: false
	Interval int64 `json:"interval,omitempty"`

	// Timeout for a single probe, in nanoseconds.
	//
	// Required: false
	Timeout int64 `json:"timeout,omitempty"`

	// StartPeriod is the initialization grace period, in nanoseconds.
	//
	// Required: false
	StartPeriod int64 `json:"startPeriod,omitempty"`

	// StartInterval is the probe interval during the start period, in nanoseconds.
	//
	// Required: false
	StartInterval int64 `json:"startInterval,omitempty"`

	// Retries is the number of consecutive failures before the container is marked unhealthy.
	//
	// Required: false
	Retries int `json:"retries,omitempty"`
}

Healthcheck represents a container's healthcheck configuration. Duration values are expressed in nanoseconds (Docker SDK convention).

type HostConfig

type HostConfig struct {
	// NetworkMode for the container.
	//
	// Required: false
	NetworkMode string `json:"networkMode,omitempty"`

	// RestartPolicy for the container.
	//
	// Required: false
	RestartPolicy string `json:"restartPolicy,omitempty"`

	// Privileged indicates if the container runs in privileged mode.
	//
	// Required: false
	Privileged bool `json:"privileged,omitempty"`

	// AutoRemove indicates if the container is removed when stopped.
	//
	// Required: false
	AutoRemove bool `json:"autoRemove,omitempty"`

	// NanoCPUs is CPU allocation in nano CPUs.
	//
	// Required: false
	NanoCPUs int64 `json:"nanoCpus,omitempty"`

	// Memory limit in bytes.
	//
	// Required: false
	Memory int64 `json:"memory,omitempty"`
}

HostConfig represents host configuration for a container.

type HostConfigCreate

type HostConfigCreate struct {
	// Binds is a list of volume bindings.
	//
	// Required: false
	Binds []string `json:"binds,omitempty"`

	// PortBindings maps container ports to host bindings.
	//
	// Required: false
	PortBindings map[string][]PortBindingCreate `json:"portBindings,omitempty"`

	// RestartPolicy for the container.
	//
	// Required: false
	RestartPolicy *RestartPolicyCreate `json:"restartPolicy,omitempty"`

	// NetworkMode for the container.
	//
	// Required: false
	NetworkMode string `json:"networkMode,omitempty"`

	// Privileged indicates if the container runs in privileged mode.
	//
	// Required: false
	Privileged *bool `json:"privileged,omitempty"`

	// AutoRemove indicates if the container is removed when stopped.
	//
	// Required: false
	AutoRemove *bool `json:"autoRemove,omitempty"`

	// Memory limit in bytes.
	//
	// Required: false
	Memory int64 `json:"memory,omitempty"`

	// MemorySwap limits total memory usage (memory + swap) in bytes.
	//
	// Required: false
	MemorySwap int64 `json:"memorySwap,omitempty"`

	// NanoCPUs is CPU allocation in nano CPUs.
	//
	// Required: false
	NanoCPUs int64 `json:"nanoCpus,omitempty"`

	// CPUShares is the relative CPU share weight.
	//
	// Required: false
	CPUShares int64 `json:"cpuShares,omitempty"`

	// ReadonlyRootfs makes the root filesystem read-only.
	//
	// Required: false
	ReadonlyRootfs *bool `json:"readonlyRootfs,omitempty"`

	// PublishAllPorts publishes all exposed ports to random host ports.
	//
	// Required: false
	PublishAllPorts *bool `json:"publishAllPorts,omitempty"`
}

HostConfigCreate represents host configuration for container creation.

type Mount

type Mount struct {
	// Type of the mount (bind, volume, tmpfs).
	//
	// Required: true
	Type string `json:"type"`

	// Name of the volume (for volume mounts).
	//
	// Required: false
	Name string `json:"name,omitempty"`

	// Source path on the host.
	//
	// Required: false
	Source string `json:"source,omitempty"`

	// Destination path in the container.
	//
	// Required: true
	Destination string `json:"destination"`

	// Driver is the volume driver (for volume mounts).
	//
	// Required: false
	Driver string `json:"driver,omitempty"`

	// Mode specifies mount permissions.
	//
	// Required: false
	Mode string `json:"mode,omitempty"`

	// RW indicates if the mount is read-write.
	//
	// Required: false
	RW bool `json:"rw,omitempty"`

	// Propagation mode for the mount.
	//
	// Required: false
	Propagation string `json:"propagation,omitempty"`
}

Mount represents a volume mount for a container.

type NetworkEndpoint

type NetworkEndpoint struct {
	// IPAMConfig contains IP address management configuration.
	//
	// Required: false
	IPAMConfig any `json:"ipamConfig,omitempty"`

	// Links to other containers.
	//
	// Required: false
	Links []string `json:"links,omitempty"`

	// Aliases for the container on this network.
	//
	// Required: false
	Aliases []string `json:"aliases,omitempty"`

	// MacAddress of the container on this network.
	//
	// Required: false
	MacAddress string `json:"macAddress,omitempty"`

	// DriverOpts contains driver-specific options.
	//
	// Required: false
	DriverOpts map[string]string `json:"driverOpts,omitempty"`

	// GwPriority is the gateway priority.
	//
	// Required: false
	GwPriority int `json:"gwPriority,omitempty"`

	// NetworkID is the ID of the network.
	//
	// Required: false
	NetworkID string `json:"networkId,omitempty"`

	// EndpointID is the ID of this endpoint.
	//
	// Required: false
	EndpointID string `json:"endpointId,omitempty"`

	// Gateway address for the network.
	//
	// Required: false
	Gateway string `json:"gateway,omitempty"`

	// IPAddress assigned to the container.
	//
	// Required: false
	IPAddress string `json:"ipAddress,omitempty"`

	// IPPrefixLen is the IP prefix length.
	//
	// Required: false
	IPPrefixLen int `json:"ipPrefixLen,omitempty"`

	// IPv6Gateway address for the network.
	//
	// Required: false
	IPv6Gateway string `json:"ipv6Gateway,omitempty"`

	// GlobalIPv6Address assigned to the container.
	//
	// Required: false
	GlobalIPv6Address string `json:"globalIPv6Address,omitempty"`

	// GlobalIPv6PrefixLen is the IPv6 prefix length.
	//
	// Required: false
	GlobalIPv6PrefixLen int `json:"globalIPv6PrefixLen,omitempty"`

	// DNSNames are DNS names for this endpoint.
	//
	// Required: false
	DNSNames []string `json:"dnsNames,omitempty"`
}

NetworkEndpoint represents network endpoint settings for a container.

type NetworkSettings

type NetworkSettings struct {
	// Networks is a map of network name to endpoint settings.
	//
	// Required: true
	Networks map[string]NetworkEndpoint `json:"networks"`
}

NetworkSettings contains network configuration for a container.

type NetworkingConfigCreate

type NetworkingConfigCreate struct {
	// EndpointsConfig maps network names to endpoint settings.
	//
	// Required: false
	EndpointsConfig map[string]EndpointSettingsCreate `json:"endpointsConfig,omitempty"`
}

NetworkingConfigCreate represents network configuration for container creation.

type Port

type Port struct {
	// IP address the port is bound to.
	//
	// Required: false
	IP string `json:"ip,omitempty"`

	// PrivatePort is the port inside the container.
	//
	// Required: true
	PrivatePort int `json:"privatePort"`

	// PublicPort is the port on the host.
	//
	// Required: false
	PublicPort int `json:"publicPort,omitempty"`

	// Type is the protocol type (tcp/udp).
	//
	// Required: true
	Type string `json:"type"`
}

Port represents a port binding for a container.

type PortBindingCreate

type PortBindingCreate struct {
	// HostIP is the IP address to bind to on the host.
	//
	// Required: false
	HostIP string `json:"hostIp,omitempty"`

	// HostPort is the port on the host.
	//
	// Required: false
	HostPort string `json:"hostPort,omitempty"`
}

PortBindingCreate represents host port bindings for container creation.

type RestartPolicyCreate

type RestartPolicyCreate struct {
	// Name of the restart policy.
	//
	// Required: false
	Name string `json:"name,omitempty"`

	// MaximumRetryCount is only used when name is on-failure.
	//
	// Required: false
	MaximumRetryCount int `json:"maximumRetryCount,omitempty"`
}

RestartPolicyCreate represents restart policy options for container creation.

type State

type State struct {
	// Status is the current status of the container.
	//
	// Required: true
	Status string `json:"status"`

	// Running indicates if the container is running.
	//
	// Required: true
	Running bool `json:"running"`

	// ExitCode is the exit code of the container process.
	//
	// Required: false
	ExitCode int `json:"exitCode,omitempty"`

	// StartedAt is when the container was started.
	//
	// Required: false
	StartedAt string `json:"startedAt,omitempty"`

	// FinishedAt is when the container finished.
	//
	// Required: false
	FinishedAt string `json:"finishedAt,omitempty"`

	// Health contains the healthcheck status, if the container defines one.
	//
	// Required: false
	Health *Health `json:"health,omitempty"`
}

State represents the state of a container.

type StatsHistorySample added in v1.17.0

type StatsHistorySample struct {
	CPUTenths        uint16 `json:"cpuTenths"`
	MemoryTenths     uint16 `json:"memoryTenths"`
	MemoryUsageBytes uint64 `json:"memoryUsageBytes"`
}

StatsHistorySample is a compact history sample for container CPU and memory usage.

type StatsStreamPayload added in v1.17.0

type StatsStreamPayload struct {
	dockercontainer.StatsResponse
	StatsHistory         []StatsHistorySample `json:"statsHistory,omitempty"`
	CurrentHistorySample StatsHistorySample   `json:"currentHistorySample"`
}

StatsStreamPayload is the container stats websocket payload.

type StatusCounts

type StatusCounts struct {
	// RunningContainers is the number of running containers.
	//
	// Required: true
	RunningContainers int `json:"runningContainers"`

	// StoppedContainers is the number of stopped containers.
	//
	// Required: true
	StoppedContainers int `json:"stoppedContainers"`

	// TotalContainers is the total number of containers.
	//
	// Required: true
	TotalContainers int `json:"totalContainers"`
}

StatusCounts contains counts of containers by status.

type Summary

type Summary struct {
	// ID is the unique identifier of the container.
	//
	// Required: true
	ID string `json:"id"`

	// Names is a list of names for the container.
	//
	// Required: true
	Names []string `json:"names"`

	// Image used by the container.
	//
	// Required: true
	Image string `json:"image"`

	// ImageID is the ID of the image.
	//
	// Required: true
	ImageID string `json:"imageId"`

	// Command running in the container.
	//
	// Required: true
	Command string `json:"command"`

	// Created is the Unix timestamp when the container was created.
	//
	// Required: true
	Created int64 `json:"created"`

	// Ports exposed by the container.
	//
	// Required: true
	Ports []Port `json:"ports"`

	// Labels contains user-defined metadata.
	//
	// Required: true
	Labels map[string]string `json:"labels"`

	// State is the current state of the container.
	//
	// Required: true
	State string `json:"state"`

	// Status provides a human-readable status.
	//
	// Required: true
	Status string `json:"status"`

	// HostConfig contains host configuration.
	//
	// Required: true
	HostConfig HostConfig `json:"hostConfig"`

	// NetworkSettings contains network configuration.
	//
	// Required: true
	NetworkSettings NetworkSettings `json:"networkSettings"`

	// Mounts lists volume mounts.
	//
	// Required: true
	Mounts []Mount `json:"mounts"`

	// UpdateInfo contains image update information for this container.
	//
	// Required: false
	UpdateInfo *imagetypes.UpdateInfo `json:"updateInfo,omitempty"`

	// RedeployDisabled indicates whether redeploy actions are disabled for this container.
	//
	// Required: false
	RedeployDisabled bool `json:"redeployDisabled,omitempty"`
}

Summary represents a container summary.

func NewSummary

func NewSummary(c container.Summary) Summary

NewSummary creates a Summary from a docker container.Summary.

type SummaryGroup added in v1.16.2

type SummaryGroup struct {
	// GroupName is the group label, such as a compose project name.
	//
	// Required: true
	GroupName string `json:"groupName"`

	// Items contains the container summaries in the group.
	//
	// Required: true
	Items []Summary `json:"items"`
}

SummaryGroup represents a group of container summaries.

Jump to

Keyboard shortcuts

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