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

common

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package common provides shared types, utilities, and constants.

Index

Constants

View Source
const (
	// DefaultConfigDir is where Doki config is stored.
	DefaultConfigDir = ".doki"
	// ConfigFileName is the name of the config file.
	ConfigFileName = "config.json"
	// DefaultSocketName is the default unix socket name.
	DefaultSocketName = "doki.sock"
)
View Source
const DokiAPIVersion = "1.55"

DokiAPIVersion is the compatible Docker Engine API version. Aligned with Docker Engine 29.6.x (June 2026) max API.

View Source
const DokiMinClient = "1.44"

DokiMinClient is the minimum API version we accept from clients. Below this we negotiate up.

View Source
const DokiVersion = "0.12.0"

DokiVersion is the current version of the Doki engine. v0.12.0: Production-ready unified runtime - Docker 80% / Podman 40% / CRI 75% Full attach/exec hijack, critest passing, Quadlets, Kube Play, OCI Artifacts, nftables/iptables auto-detect, cgroup v2 manager, plugins stubs.

Variables

View Source
var (
	// Version is the effective runtime version. It defaults to DokiVersion
	// but is overridden at build time via -ldflags.
	Version = DokiVersion
	// GitCommit is the short git commit SHA at build time. "unknown" in dev.
	GitCommit = "unknown"
	// BuildDate is the RFC3339 build timestamp. "unknown" in dev.
	BuildDate = "unknown"
	// BuildUser is the user that built the binary (from $USER). "unknown" in CI.
	BuildUser = "unknown"
	// GoVersion is captured at init() (not via ldflags) to keep the build simple.
	GoVersion = runtime.Version()
)

Build-time injected variables. Override with -ldflags "-X":

-X github.com/OpceanAI/Doki/pkg/common.DokiGitCommit=$(git rev-parse --short HEAD)
-X github.com/OpceanAI/Doki/pkg/common.DokiBuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)
-X github.com/OpceanAI/Doki/pkg/common.DokiVersion=$(git describe --tags --always --dirty)

Functions

func AndroidEnv added in v0.9.3

func AndroidEnv() []string

AndroidEnv returns the safe defaults injected into every container's environment. It deliberately uses POSIX paths (/usr/bin, /bin, /root, /tmp) that exist in every glibc and musl based rootfs, instead of Termux-specific paths.

See OpceanAI/Doki#4: without these defaults, the guest sees PREFIX=/data/... and HOME=/data/.../files/home, neither of which exist, so init shells crash on first read of $HOME or $TMPDIR.

func AppDataDir

func AppDataDir() string

AppDataDir returns the platform-specific data directory.

func ArgsEscaped

func ArgsEscaped(args []string) bool

ArgsEscaped checks if command args need shell escaping.

func CommandExists

func CommandExists(cmd string) bool

CommandExists checks if a command exists in PATH.

func ContainerDir

func ContainerDir() string

ContainerDir returns the Doki container directory.

func ContainerID

func ContainerID() string

ContainerID generates a 64-character container ID.

func ContainsString

func ContainsString(slice []string, s string) bool

ContainsString checks if a slice contains a string.

func CopyDir

func CopyDir(src, dst string) error

CopyDir recursively copies a directory.

func DataDir

func DataDir() string

DataDir returns the Doki data directory.

func DefaultCRISocket added in v0.11.1

func DefaultCRISocket() string

DefaultCRISocket returns the default Unix socket path for the CRI service.

func DefaultDaemonSocket

func DefaultDaemonSocket() string

DefaultDaemonSocket returns the default daemon socket path.

func EnsureDir

func EnsureDir(path string) error

EnsureDir creates a directory if it doesn't exist.

func FullVersion

func FullVersion() string

FullVersion returns a human-readable banner used in --version and startup logs.

"Doki 0.9.2 (commit a1b2c3d, built 2026-06-02T14:00:00Z by root), API 1.48 (min 1.43)"

func GenerateID

func GenerateID(length int) string

GenerateID generates a random hex ID of the given length.

func HasLibTermuxExec added in v0.9.3

func HasLibTermuxExec() bool

HasLibTermuxExec reports whether the libtermux-exec-ld-preload.so file is present in the Termux lib directory. Doki uses this to decide whether the workaround (os.Unsetenv("LD_PRELOAD")) is required before launching proot.

func HasSystemd

func HasSystemd() bool

HasSystemd checks if the system uses systemd as init.

func ImageDir

func ImageDir() string

ImageDir returns the Doki image directory.

func InternString

func InternString(s string) string

func IsConflict added in v0.9.3

func IsConflict(err error) bool

IsConflict checks if an error is an ErrConflict.

func IsNotFound added in v0.9.3

func IsNotFound(err error) bool

IsNotFound checks if an error is an ErrNotFound.

func IsProotMode added in v0.9.3

func IsProotMode() bool

IsProotMode reports whether the current process is running under proot. Detection uses three signals in order:

  1. DOKI_PROOT=1 (explicit override, set by proot runners)
  2. PROOT_TMP_DIR (libtermux-exec sets this when entering proot)
  3. Termux + missing /proc/self/cgroup namespace marker (heuristic)

func IsSensitiveBindSource added in v0.12.0

func IsSensitiveBindSource(source string) bool

IsSensitiveBindSource reports whether a host path is too dangerous to expose as a container bind mount source (HIGH-12). Mounting the host root or a system directory read-write is effectively a host takeover, so every API surface that accepts a bind must run its source through this one check.

func IsTermux added in v0.9.3

func IsTermux() bool

func LogDir

func LogDir() string

LogDir returns the platform-specific log directory.

func MergeEnv

func MergeEnv(base, overrides []string) []string

MergeEnv merges two environment slices.

func NetworkDir

func NetworkDir() string

NetworkDir returns the Doki network directory.

func NewErrConflict

func NewErrConflict(resource, id string) error

NewErrConflict creates a new ErrConflict.

func NewErrInvalidParam

func NewErrInvalidParam(param, message string) error

NewErrInvalidParam creates a new ErrInvalidParam.

func NewErrNotFound

func NewErrNotFound(resource, id string) error

NewErrNotFound creates a new ErrNotFound.

func NowTimestamp

func NowTimestamp() int64

NowTimestamp returns the current Unix timestamp.

func OSType

func OSType() string

OSType returns the operating system type.

func ParseEnv

func ParseEnv(env string) (string, string)

ParseEnv splits an environment variable into key and value.

func ParsePortBinding

func ParsePortBinding(binding string) (Port, PortBinding, error)

ParsePortBinding parses a Docker port binding string like "8080:80/tcp".

func PathExists

func PathExists(path string) bool

PathExists checks if a path exists on the filesystem.

func ProotContainerIP added in v0.9.3

func ProotContainerIP(logicalIP string) string

ProotContainerIP resolves a logical Docker bridge IP (e.g. 172.17.0.2) to the address the host should use to reach the container. In proot+Termux mode this is always 127.0.0.1; elsewhere the original IP is returned.

func RemoveString

func RemoveString(slice []string, s string) []string

RemoveString removes a string from a slice.

func ResolvePath

func ResolvePath(base, path string) string

ResolvePath resolves a path relative to a base directory.

func RuntimeDir

func RuntimeDir() string

RuntimeDir returns the Doki runtime directory.

func SafeFileMode added in v0.10.0

func SafeFileMode(v int64) os.FileMode

SafeFileMode converts an int64 (e.g. tar.Header.Mode) to os.FileMode without triggering gosec G115. Negative modes collapse to 0.

func SafeInt64FromUint64 added in v0.10.0

func SafeInt64FromUint64(v uint64) int64

SafeInt64FromUint64 converts a uint64 to int64, clamping values larger than math.MaxInt64 down to math.MaxInt64. Use this anywhere gosec G115 flags an implicit uint64→int64 conversion (disk sizes, file sizes, byte counters).

func SafeUint32FromInt64 added in v0.10.0

func SafeUint32FromInt64(v int64) uint32

SafeUint32FromInt64 converts an int64 to uint32, treating negative values as zero. Used for tar header mode fields (os.FileMode / syscall mode bits).

func SafeUint64FromInt64 added in v0.10.0

func SafeUint64FromInt64(v int64) uint64

SafeUint64FromInt64 converts an int64 to uint64, treating negative values as zero. Use this anywhere gosec G115 flags an implicit int64→uint64 conversion (counts, periods, quotas that semantically are non-negative).

func SaveConfig

func SaveConfig(cfg *DokiConfig) error

SaveConfig saves the Doki configuration to disk.

func SecureJoin added in v0.12.0

func SecureJoin(root, unsafePath string) (string, error)

SecureJoin resolves unsafePath beneath root, following any symlink components that already exist on disk but clamping every result to root — absolute symlink targets and ".." are interpreted as if root were "/", exactly like a chroot. The returned path is guaranteed to be within root. Trailing components that do not yet exist are appended literally.

This is the defense against symlink-based path-traversal escapes during extraction and container file copy (CVE-2018-15664 class): resolve the PARENT directory of a target through SecureJoin, then join the final path element yourself so an existing symlink at the leaf is replaced rather than followed.

func ShortID

func ShortID(id string) string

ShortID truncates an ID to 12 characters.

func SplitStrSlice

func SplitStrSlice(s string) []string

SplitStrSlice splits a string by commas and trims whitespace.

func StripHostEnv

func StripHostEnv(env []string) []string

StripHostEnv removes host-specific environment variables that interfere with proot (ptrace-based container runtime). Notably LD_PRELOAD from Termux hooks execve and breaks proot's ptrace mechanism, and several other Termux/Android variables leak host paths into the guest.

The full deny-list lives in termuxAndroidDenyList. On non-Android hosts the deny-list is harmless because none of the variable names are typically set.

func StripHostEnvFromOS added in v0.9.3

func StripHostEnvFromOS() []string

StripHostEnvFromOS is a convenience that calls StripHostEnv on the current process environment. It also unsets the denied variables in the process itself so that any child process spawned via exec.Command inherits a clean environment unless cmd.Env is explicitly set.

func SystemdListenFDs

func SystemdListenFDs() []*os.File

SystemdListenFDs returns file descriptors passed by systemd socket activation.

func TermuxLibPath added in v0.9.3

func TermuxLibPath() string

TermuxLibPath returns the path where Termux stores its Bionic and libtermux-exec.so. It is the directory the LD_PRELOAD points to, and the path the kernel uses to resolve libtermux-exec.so.1 at exec time.

func TermuxPrefix added in v0.9.3

func TermuxPrefix() string

TermuxPrefix returns the absolute path of the Termux $PREFIX, falling back to the canonical /data/data/com.termux/files/usr when no env var is set. The returned path always has no trailing slash.

func TermuxVersion added in v0.9.3

func TermuxVersion() string

TermuxVersion returns the value of $TERMUX_VERSION or "unknown" when the variable is unset. Used for diagnostic output in --doki-trace and in actionable error messages.

func TimeToTimestamp

func TimeToTimestamp(t time.Time) int64

TimeToTimestamp converts time.Time to Unix timestamp.

func TrimQuotes

func TrimQuotes(s string) string

TrimQuotes strips surrounding quotes from a string.

func UseProotHostNetworking added in v0.9.3

func UseProotHostNetworking() bool

UseProotHostNetworking reports whether DokiLink should use host-loopback (127.0.0.1) port forwards instead of bridge IPs. In proot mode the container shares the host netns, so bridge IPs (e.g. 172.17.0.2) are unreachable from the host; loopback works because proot fakes it.

func UserAgent

func UserAgent() string

UserAgent returns the User-Agent string for outbound HTTP requests (registries, OCI distribution, etc.). Mirrors the Docker CLI format.

func ValidContainerName

func ValidContainerName(name string) bool

func ValidateDigest added in v0.12.0

func ValidateDigest(d string) error

ValidateDigest reports an error unless d is a strictly formed digest of a supported algorithm. Callers MUST validate every digest that originates from a registry manifest before using it as (part of) a filesystem path.

func ValidateEnv

func ValidateEnv(env []string) []string

ValidateEnv validates env vars and applies size limits.

func ValidateEnvVar

func ValidateEnvVar(name string) bool

ValidateEnvVar checks if an environment variable name is valid per POSIX.

func VolumeDir

func VolumeDir() string

VolumeDir returns the Doki volume directory.

func WriteFileSafe

func WriteFileSafe(path, content string, mode os.FileMode) error

WriteFileSafe writes content to a file, creating parent directories.

Types

type BindOptions

type BindOptions struct {
	Propagation            string `json:"Propagation,omitempty"`
	NonRecursive           bool   `json:"NonRecursive,omitempty"`
	CreateMountpoint       bool   `json:"CreateMountpoint,omitempty"`
	ReadOnlyNonRecursive   bool   `json:"ReadOnlyNonRecursive,omitempty"`
	ReadOnlyForceRecursive bool   `json:"ReadOnlyForceRecursive,omitempty"`
}

BindOptions for bind mounts.

type ContainerConfig

type ContainerConfig struct {
	Hostname     string              `json:"Hostname"`
	Domainname   string              `json:"Domainname"`
	User         string              `json:"User"`
	AttachStdin  bool                `json:"AttachStdin"`
	AttachStdout bool                `json:"AttachStdout"`
	AttachStderr bool                `json:"AttachStderr"`
	ExposedPorts map[string]struct{} `json:"ExposedPorts"`
	Tty          bool                `json:"Tty"`
	OpenStdin    bool                `json:"OpenStdin"`
	StdinOnce    bool                `json:"StdinOnce"`
	Env          []string            `json:"Env"`
	Cmd          []string            `json:"Cmd"`
	Image        string              `json:"Image"`
	Volumes      map[string]struct{} `json:"Volumes"`
	WorkingDir   string              `json:"WorkingDir"`
	Entrypoint   []string            `json:"Entrypoint"`
	Labels       map[string]string   `json:"Labels"`
	StopSignal   string              `json:"StopSignal"`
	StopTimeout  *int                `json:"StopTimeout,omitempty"`
	Shell        []string            `json:"Shell"`
}

ContainerConfig holds container-specific configuration.

type ContainerInfo

type ContainerInfo struct {
	ID              string            `json:"Id"`
	Name            string            `json:"Name"`
	Image           string            `json:"Image"`
	ImageID         string            `json:"ImageID"`
	Command         string            `json:"Command"`
	Created         int64             `json:"Created"`
	State           ContainerState    `json:"State"`
	Status          string            `json:"Status"`
	Ports           []Port            `json:"Ports"`
	Labels          map[string]string `json:"Labels"`
	Names           []string          `json:"Names"`
	SizeRw          int64             `json:"SizeRw,omitempty"`
	SizeRootFs      int64             `json:"SizeRootFs,omitempty"`
	HostConfig      *HostConfig       `json:"HostConfig,omitempty"`
	NetworkSettings *NetworkSettings  `json:"NetworkSettings,omitempty"`
	Mounts          []MountPoint      `json:"Mounts"`
}

ContainerInfo holds the information about a container.

type ContainerJSON

type ContainerJSON struct {
	*ContainerInfo
	Config          *ContainerConfig `json:"Config"`
	HostConfig      *HostConfig      `json:"HostConfig"`
	Image           string           `json:"Image"`
	ImageID         string           `json:"ImageID"`
	Name            string           `json:"Name"`
	ResolvConfPath  string           `json:"ResolvConfPath"`
	HostnamePath    string           `json:"HostnamePath"`
	HostsPath       string           `json:"HostsPath"`
	LogPath         string           `json:"LogPath"`
	RestartCount    int              `json:"RestartCount"`
	Driver          string           `json:"Driver"`
	Platform        string           `json:"Platform"`
	MountLabel      string           `json:"MountLabel"`
	ProcessLabel    string           `json:"ProcessLabel"`
	AppArmorProfile string           `json:"AppArmorProfile"`
	GraphDriver     *GraphDriverData `json:"GraphDriver"`
}

ContainerJSON holds full container information.

type ContainerState

type ContainerState string

ContainerState represents the state of a container.

const (
	StateCreated    ContainerState = "created"
	StateRunning    ContainerState = "running"
	StatePaused     ContainerState = "paused"
	StateRestarting ContainerState = "restarting"
	StateRemoving   ContainerState = "removing"
	StateExited     ContainerState = "exited"
	StateDead       ContainerState = "dead"
)

type ContainerStatus

type ContainerStatus string

ContainerStatus represents the status string for a container.

const (
	StatusCreated    ContainerStatus = "created"
	StatusRunning    ContainerStatus = "running"
	StatusPaused     ContainerStatus = "paused"
	StatusRestarting ContainerStatus = "restarting"
	StatusRemoving   ContainerStatus = "removing"
	StatusExited     ContainerStatus = "exited"
	StatusDead       ContainerStatus = "dead"
	StatusUp         ContainerStatus = "up"
)

type DeviceMapping

type DeviceMapping struct {
	PathOnHost        string `json:"PathOnHost"`
	PathInContainer   string `json:"PathInContainer"`
	CgroupPermissions string `json:"CgroupPermissions"`
}

DeviceMapping represents a device mapping between host and container.

type DokiConfig

type DokiConfig struct {
	Root               string            `json:"root"`
	SocketPath         string            `json:"socket_path"`
	StorageDriver      string            `json:"storage_driver"`
	DefaultNetwork     string            `json:"default_network"`
	Debug              bool              `json:"debug"`
	LogLevel           string            `json:"log_level"`
	Rootless           bool              `json:"rootless"`
	DataDir            string            `json:"data_dir"`
	ExecRoot           string            `json:"exec_root"`
	DNS                []string          `json:"dns"`
	DNSSearch          []string          `json:"dns_search"`
	DNSOptions         []string          `json:"dns_options"`
	DefaultUlimits     map[string]Ulimit `json:"default_ulimits"`
	RegistryMirrors    []string          `json:"registry_mirrors"`
	InsecureRegistries []string          `json:"insecure_registries"`

	// VM Configuration (doki-OS)
	VMImage      string `json:"vm_image,omitempty"`
	VMCPUs       int    `json:"vm_cpus,omitempty"`
	VMMemoryMB   int64  `json:"vm_memory_mb,omitempty"`
	VMDiskSizeGB int64  `json:"vm_disk_size_gb,omitempty"`
	VMForce      bool   `json:"vm_force,omitempty"`
}

DokiConfig holds the configuration for the Doki daemon.

func DefaultConfig

func DefaultConfig() *DokiConfig

DefaultConfig returns the default Doki configuration.

func LoadConfig

func LoadConfig() (*DokiConfig, error)

LoadConfig loads the Doki configuration from disk.

func LoadConfigFrom

func LoadConfigFrom(path string) (*DokiConfig, error)

LoadConfigFrom loads the configuration from an explicit file path. Returns a default config with the error wrapped if the file is missing (callers can decide whether to fall back).

type DriverConfig

type DriverConfig struct {
	Name    string            `json:"Name,omitempty"`
	Options map[string]string `json:"Options,omitempty"`
}

DriverConfig for volumes.

type EndpointIPAMConfig

type EndpointIPAMConfig struct {
	IPv4Address string `json:"IPv4Address,omitempty"`
	IPv6Address string `json:"IPv6Address,omitempty"`
}

EndpointIPAMConfig represents IPAM configuration for an endpoint.

type EndpointResource

type EndpointResource struct {
	Name        string `json:"Name,omitempty"`
	EndpointID  string `json:"EndpointID"`
	MacAddress  string `json:"MacAddress"`
	IPv4Address string `json:"IPv4Address"`
	IPv6Address string `json:"IPv6Address"`
}

EndpointResource contains network resources allocated for an endpoint.

type EndpointSettings

type EndpointSettings struct {
	IPAMConfig  *EndpointIPAMConfig `json:"IPAMConfig,omitempty"`
	Links       []string            `json:"Links,omitempty"`
	Aliases     []string            `json:"Aliases,omitempty"`
	NetworkID   string              `json:"NetworkID"`
	EndpointID  string              `json:"EndpointID"`
	Gateway     string              `json:"Gateway"`
	IPAddress   string              `json:"IPAddress"`
	IPPrefixLen int                 `json:"IPPrefixLen"`
	MacAddress  string              `json:"MacAddress"`
}

EndpointSettings holds network endpoint configuration.

type ErrConflict

type ErrConflict struct {
	Resource string
	ID       string
}

ErrConflict is returned when a resource already exists.

func (*ErrConflict) Error

func (e *ErrConflict) Error() string

func (*ErrConflict) Is

func (e *ErrConflict) Is(target error) bool

type ErrContainerPaused

type ErrContainerPaused struct {
	ID string
}

ErrContainerPaused is returned when a container is paused.

func (*ErrContainerPaused) Error

func (e *ErrContainerPaused) Error() string

type ErrContainerStopped

type ErrContainerStopped struct {
	ID string
}

ErrContainerStopped is returned when trying to operate on a stopped container.

func (*ErrContainerStopped) Error

func (e *ErrContainerStopped) Error() string

type ErrInvalidParam

type ErrInvalidParam struct {
	Param   string
	Message string
}

ErrInvalidParam is returned when a parameter is invalid.

func (*ErrInvalidParam) Error

func (e *ErrInvalidParam) Error() string

type ErrNotFound

type ErrNotFound struct {
	Resource string
	ID       string
}

ErrNotFound is returned when a resource is not found.

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

func (*ErrNotFound) Is

func (e *ErrNotFound) Is(target error) bool

type ErrNotImplemented

type ErrNotImplemented struct {
	Feature string
}

ErrNotImplemented is returned when a feature is not yet implemented.

func (*ErrNotImplemented) Error

func (e *ErrNotImplemented) Error() string

type ErrPermissionDenied

type ErrPermissionDenied struct {
	Message string
}

ErrPermissionDenied is returned when permission is denied.

func (*ErrPermissionDenied) Error

func (e *ErrPermissionDenied) Error() string

type EventActor

type EventActor struct {
	ID         string            `json:"ID"`
	Attributes map[string]string `json:"Attributes"`
}

EventActor describes something that generates events.

type ExecConfig

type ExecConfig struct {
	ID           string   `json:"Id"`
	ContainerID  string   `json:"ContainerID,omitempty"`
	AttachStdin  bool     `json:"AttachStdin"`
	AttachStdout bool     `json:"AttachStdout"`
	AttachStderr bool     `json:"AttachStderr"`
	Tty          bool     `json:"Tty"`
	Cmd          []string `json:"Cmd"`
	Env          []string `json:"Env"`
	WorkingDir   string   `json:"WorkingDir"`
	User         string   `json:"User"`
	Privileged   bool     `json:"Privileged"`
	Running      bool     `json:"Running"`
	ExitCode     int      `json:"ExitCode"`
	Pid          int      `json:"Pid"`
}

ExecConfig holds configuration for an exec instance.

type GraphDriverData

type GraphDriverData struct {
	Name string            `json:"Name"`
	Data map[string]string `json:"Data"`
}

GraphDriverData holds information about the storage driver.

type HealthCheckResult

type HealthCheckResult struct {
	Start    time.Time `json:"Start"`
	End      time.Time `json:"End"`
	ExitCode int       `json:"ExitCode"`
	Output   string    `json:"Output"`
}

HealthCheckResult stores the result of a healthcheck probe.

type HealthStatus

type HealthStatus struct {
	Status        string              `json:"Status"`
	FailingStreak int                 `json:"FailingStreak"`
	Log           []HealthCheckResult `json:"Log"`
}

HealthStatus represents the health status.

type HostConfig

type HostConfig struct {
	Binds           []string            `json:"Binds"`
	NetworkMode     NetworkMode         `json:"NetworkMode"`
	PortBindings    PortMap             `json:"PortBindings"`
	RestartPolicy   RestartPolicyConfig `json:"RestartPolicy"`
	AutoRemove      bool                `json:"AutoRemove"`
	Privileged      bool                `json:"Privileged"`
	PublishAllPorts bool                `json:"PublishAllPorts"`
	ReadonlyRootfs  bool                `json:"ReadonlyRootfs"`
	DNS             []string            `json:"Dns"`
	DNSOptions      []string            `json:"DnsOptions"`
	DNSSearch       []string            `json:"DnsSearch"`
	ExtraHosts      []string            `json:"ExtraHosts"`
	VolumesFrom     []string            `json:"VolumesFrom"`
	CapAdd          []string            `json:"CapAdd"`
	CapDrop         []string            `json:"CapDrop"`
	Sysctls         map[string]string   `json:"Sysctls"`
	ShmSize         int64               `json:"ShmSize"`
	Tmpfs           map[string]string   `json:"Tmpfs"`
	Ulimits         []Ulimit            `json:"Ulimits"`
	SecurityOpt     []string            `json:"SecurityOpt"`
	Mounts          []Mount             `json:"Mounts"`
	Init            bool                `json:"Init"`
	Runtime         string              `json:"Runtime"`
	Isolation       string              `json:"Isolation"`
	CPUShares       int64               `json:"CpuShares"`
	Memory          int64               `json:"Memory"`
	NanoCpus        int64               `json:"NanoCpus"`
	CgroupParent    string              `json:"CgroupParent"`
	BlkioWeight     uint16              `json:"BlkioWeight"`
	PidsLimit       int64               `json:"PidsLimit"`
	OomKillDisable  bool                `json:"OomKillDisable"`
	OomScoreAdj     int64               `json:"OomScoreAdj"`
}

HostConfig is the host-dependent container configuration.

type IPAM

type IPAM struct {
	Driver  string            `json:"Driver"`
	Options map[string]string `json:"Options,omitempty"`
	Config  []IPAMConfig      `json:"Config"`
}

IPAM represents IP address management configuration.

type IPAMConfig

type IPAMConfig struct {
	Subnet  string `json:"Subnet,omitempty"`
	Gateway string `json:"Gateway,omitempty"`
	IPRange string `json:"IPRange,omitempty"`
}

IPAMConfig represents IPAM configuration for a network.

type ImageInfo

type ImageInfo struct {
	ID           string            `json:"Id"`
	RepoTags     []string          `json:"RepoTags"`
	RepoDigests  []string          `json:"RepoDigests"`
	Parent       string            `json:"Parent"`
	Comment      string            `json:"Comment"`
	Created      int64             `json:"Created"`
	Container    string            `json:"Container"`
	Size         int64             `json:"Size"`
	VirtualSize  int64             `json:"VirtualSize"`
	Author       string            `json:"Author"`
	Architecture string            `json:"Architecture"`
	Os           string            `json:"Os"`
	Labels       map[string]string `json:"Labels"`
}

ImageInfo holds information about an image.

type ImageRef

type ImageRef struct {
	Registry string
	Name     string
	Tag      string
	Digest   string
}

ImageRef represents a parsed image reference.

func ParseImageRef

func ParseImageRef(ref string) (*ImageRef, error)

ParseImageRef parses a Docker image reference string into its components.

func ParseImageRefString

func ParseImageRefString(ref string) (*ImageRef, error)

ParseImageRefString parses an image reference. Supports formats: name, name:tag, registry/name, registry/name:tag, registry:port/name, registry:port/name:tag, name@digest, name:tag@digest

type LogDriver

type LogDriver string

LogDriver is the logging driver for containers.

const (
	LogJSONFile LogDriver = "json-file"
	LogSyslog   LogDriver = "syslog"
	LogJournald LogDriver = "journald"
	LogNone     LogDriver = "none"
)

type Mount

type Mount struct {
	Type          MountType      `json:"Type"`
	Source        string         `json:"Source,omitempty"`
	Target        string         `json:"Target"`
	ReadOnly      bool           `json:"ReadOnly,omitempty"`
	Consistency   string         `json:"Consistency,omitempty"`
	BindOptions   *BindOptions   `json:"BindOptions,omitempty"`
	VolumeOptions *VolumeOptions `json:"VolumeOptions,omitempty"`
	TmpfsOptions  *TmpfsOptions  `json:"TmpfsOptions,omitempty"`
}

Mount represents a mount point inside a container.

type MountPoint

type MountPoint struct {
	Type        MountType `json:"Type"`
	Name        string    `json:"Name,omitempty"`
	Source      string    `json:"Source"`
	Destination string    `json:"Destination"`
	Driver      string    `json:"Driver,omitempty"`
	Mode        string    `json:"Mode"`
	RW          bool      `json:"RW"`
	Propagation string    `json:"Propagation,omitempty"`
}

MountPoint describes a mount point inside a container.

type MountType

type MountType string

MountType represents the type of a mount.

const (
	MountBind    MountType = "bind"
	MountVolume  MountType = "volume"
	MountTmpfs   MountType = "tmpfs"
	MountNpipe   MountType = "npipe"
	MountCluster MountType = "cluster"
)

type NetworkInfo

type NetworkInfo struct {
	ID         string                      `json:"Id"`
	Name       string                      `json:"Name"`
	Driver     string                      `json:"Driver"`
	Scope      string                      `json:"Scope"`
	Internal   bool                        `json:"Internal"`
	EnableIPv6 bool                        `json:"EnableIPv6"`
	IPAM       *IPAM                       `json:"IPAM"`
	Options    map[string]string           `json:"Options"`
	Labels     map[string]string           `json:"Labels"`
	Containers map[string]EndpointResource `json:"Containers"`
	Created    time.Time                   `json:"Created"`
}

NetworkInfo holds information about a network.

type NetworkMode

type NetworkMode string

NetworkMode represents the networking mode for a container.

const (
	NetworkBridge    NetworkMode = "bridge"
	NetworkHost      NetworkMode = "host"
	NetworkNone      NetworkMode = "none"
	NetworkContainer NetworkMode = "container"
)

type NetworkSettings

type NetworkSettings struct {
	Networks map[string]*EndpointSettings `json:"Networks"`
}

NetworkSettings holds network-related information for a container.

type Port

type Port struct {
	IP          string       `json:"IP,omitempty"`
	PrivatePort uint16       `json:"PrivatePort"`
	PublicPort  uint16       `json:"PublicPort,omitempty"`
	Type        PortProtocol `json:"Type"`
}

Port represents an open port on a container.

type PortBinding

type PortBinding struct {
	HostIP   string `json:"HostIp,omitempty"`
	HostPort string `json:"HostPort,omitempty"`
}

PortBinding represents a port binding between host and container.

type PortMap

type PortMap map[string][]PortBinding

PortMap is a collection of port bindings keyed by port+proto (e.g. "80/tcp").

type PortProtocol

type PortProtocol string

Port protocol types.

const (
	ProtocolTCP  PortProtocol = "tcp"
	ProtocolUDP  PortProtocol = "udp"
	ProtocolSCTP PortProtocol = "sctp"
)

type RestartPolicy

type RestartPolicy string

RestartPolicy represents container restart behavior.

const (
	RestartNo            RestartPolicy = "no"
	RestartAlways        RestartPolicy = "always"
	RestartUnlessStopped RestartPolicy = "unless-stopped"
	RestartOnFailure     RestartPolicy = "on-failure"
)

type RestartPolicyConfig

type RestartPolicyConfig struct {
	Name              string `json:"Name"`
	MaximumRetryCount int    `json:"MaximumRetryCount"`
}

RestartPolicyConfig describes container restart behavior.

type SearchResult

type SearchResult struct {
	Name        string `json:"repo_name"`
	Description string `json:"short_description"`
	StarCount   int    `json:"star_count"`
	IsOfficial  bool   `json:"is_official"`
	IsAutomated bool   `json:"is_automated"`
}

SearchResult is returned from image search.

type SystemEventsResponse

type SystemEventsResponse struct {
	Status   string     `json:"status"`
	ID       string     `json:"id"`
	From     string     `json:"from"`
	Type     string     `json:"Type"`
	Action   string     `json:"Action"`
	Actor    EventActor `json:"Actor"`
	Time     int64      `json:"time"`
	TimeNano int64      `json:"timeNano"`
}

SystemEventsResponse holds events from the system.

type SystemInfo

type SystemInfo struct {
	ID                string      `json:"ID"`
	Name              string      `json:"Name"`
	ServerVersion     string      `json:"ServerVersion"`
	OSType            string      `json:"OSType"`
	OperatingSystem   string      `json:"OperatingSystem"`
	Architecture      string      `json:"Architecture"`
	NCPU              int         `json:"NCPU"`
	MemTotal          int64       `json:"MemTotal"`
	Driver            string      `json:"Driver"`
	DriverStatus      [][2]string `json:"DriverStatus"`
	DockerRootDir     string      `json:"DockerRootDir"`
	Images            int         `json:"Images"`
	Containers        int         `json:"Containers"`
	ContainersRunning int         `json:"ContainersRunning"`
	ContainersPaused  int         `json:"ContainersPaused"`
	ContainersStopped int         `json:"ContainersStopped"`
	// SecurityOptions lists the isolation features actually enforced by this
	// daemon. Populated honestly (C1): features that are currently no-ops (e.g.
	// seccomp/apparmor in rootless/proot mode) are NOT reported as active.
	SecurityOptions []string `json:"SecurityOptions,omitempty"`
}

SystemInfo holds system-wide information.

type TmpfsOptions

type TmpfsOptions struct {
	SizeBytes int64  `json:"SizeBytes,omitempty"`
	Mode      uint32 `json:"Mode,omitempty"`
}

TmpfsOptions for tmpfs mounts.

type Ulimit

type Ulimit struct {
	Name string `json:"Name"`
	Soft int64  `json:"Soft"`
	Hard int64  `json:"Hard"`
}

Ulimit defines a resource limit.

type VersionInfo

type VersionInfo struct {
	Version       string `json:"Version"`
	APIVersion    string `json:"ApiVersion"`
	MinAPIVersion string `json:"MinAPIVersion"`
	GitCommit     string `json:"GitCommit"`
	GoVersion     string `json:"GoVersion"`
	Os            string `json:"Os"`
	Arch          string `json:"Arch"`
	BuildDate     string `json:"BuildDate,omitempty"`
	BuildUser     string `json:"BuildUser,omitempty"`
	Experimental  bool   `json:"Experimental"`
}

VersionInfo holds the structured version payload returned by the /v1.41/version endpoint and emitted on startup logs.

func GetVersion

func GetVersion() *VersionInfo

GetVersion returns the current VersionInfo snapshot.

type VolumeInfo

type VolumeInfo struct {
	Name       string            `json:"Name"`
	Driver     string            `json:"Driver"`
	Mountpoint string            `json:"Mountpoint"`
	Labels     map[string]string `json:"Labels"`
	Scope      string            `json:"Scope"`
	Options    map[string]string `json:"Options"`
	CreatedAt  time.Time         `json:"CreatedAt"`
}

VolumeInfo holds information about a volume.

type VolumeOptions

type VolumeOptions struct {
	NoCopy       bool              `json:"NoCopy,omitempty"`
	Labels       map[string]string `json:"Labels,omitempty"`
	DriverConfig *DriverConfig     `json:"DriverConfig,omitempty"`
}

VolumeOptions for volume mounts.

Jump to

Keyboard shortcuts

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