dockercompat

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: Apache-2.0 Imports: 21 Imported by: 9

Documentation

Overview

Package dockercompat mimics `docker inspect` objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMountProperties

func ParseMountProperties(option []string) (rw bool, propagation string)

Types

type CPUSettings added in v2.0.5

type CPUSettings struct {
	CPUSetCpus         string
	CPUSetMems         string
	CPUShares          uint64
	CPUQuota           int64
	CPUPeriod          uint64
	CPURealtimePeriod  uint64
	CPURealtimeRuntime int64
}

type ClientVersion

type ClientVersion struct {
	Version    string
	GitCommit  string
	GoVersion  string
	Os         string             // GOOS
	Arch       string             // GOARCH
	Components []ComponentVersion // nerdctl extension
}

ClientVersion is from https://github.com/docker/cli/blob/v20.10.8/cli/command/system/version.go#L74-L87

type ComponentVersion

type ComponentVersion struct {
	Name    string
	Version string
	Details map[string]string `json:",omitempty"`
}

ComponentVersion describes the version information for a specific component. From https://github.com/moby/moby/blob/v20.10.8/api/types/types.go#L112-L117

type Config

type Config struct {
	Hostname    string `json:",omitempty"` // Hostname
	Domainname  string `json:",omitempty"` // Domainname
	User        string `json:",omitempty"` // User that will run the command(s) inside the container, also support user:group
	AttachStdin bool   // Attach the standard input, makes possible user interaction
	// TODO: AttachStdout bool        // Attach the standard output
	// TODO: AttachStderr bool        // Attach the standard error
	ExposedPorts nat.PortSet `json:",omitempty"` // List of exposed ports
	// TODO: Tty          bool        // Attach standard streams to a tty, including stdin if it is not closed.
	// TODO: OpenStdin    bool        // Open stdin
	// TODO: StdinOnce    bool        // If true, close stdin after the 1 attached client disconnects.
	Env []string `json:",omitempty"` // List of environment variable to set in the container
	Cmd []string `json:",omitempty"` // Command to run when starting the container
	// TODO Healthcheck     *HealthConfig       `json:",omitempty"` // Healthcheck describes how to check the container is healthy
	// TODO: ArgsEscaped     bool                `json:",omitempty"` // True if command is already escaped (meaning treat as a command line) (Windows specific).
	// TODO: Image           string              // Name of the image as it was passed by the operator (e.g. could be symbolic)
	Volumes    map[string]struct{} `json:",omitempty"` // List of volumes (mounts) used for the container
	WorkingDir string              `json:",omitempty"` // Current directory (PWD) in the command will be launched
	Entrypoint []string            `json:",omitempty"` // Entrypoint to run when starting the container
	// TODO: NetworkDisabled bool                `json:",omitempty"` // Is network disabled
	// TODO: MacAddress      string              `json:",omitempty"` // Mac Address of the container
	// TODO: OnBuild         []string            // ONBUILD metadata that were defined on the image Dockerfile
	Labels map[string]string `json:",omitempty"` // List of labels set to this container

}

config is from https://github.com/moby/moby/blob/8dbd90ec00daa26dc45d7da2431c965dec99e8b4/api/types/container/config.go#L37-L69

type Container

type Container struct {
	ID             string `json:"Id"`
	Created        string
	Path           string
	Args           []string
	State          *ContainerState
	Image          string
	ResolvConfPath string
	HostnamePath   string
	HostsPath      string
	LogPath        string
	// Unimplemented: Node            *ContainerNode `json:",omitempty"` // Node is only propagated by Docker Swarm standalone API
	Name         string
	RestartCount int
	Driver       string
	Platform     string
	// TODO: MountLabel      string
	// TODO: ProcessLabel    string
	AppArmorProfile string
	// TODO: ExecIDs         []string
	HostConfig *HostConfig
	// TODO: GraphDriver     GraphDriverData
	SizeRw     *int64 `json:",omitempty"`
	SizeRootFs *int64 `json:",omitempty"`

	Mounts          []MountPoint
	Config          *Config
	NetworkSettings *NetworkSettings
}

Container mimics a `docker container inspect` object. From https://github.com/moby/moby/blob/v20.10.1/api/types/types.go#L340-L374

func ContainerFromNative

func ContainerFromNative(n *native.Container) (*Container, error)

ContainerFromNative instantiates a Docker-compatible Container from containerd-native Container.

type ContainerState

type ContainerState struct {
	Status     string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
	Running    bool
	Paused     bool
	Restarting bool
	// TODO: OOMKilled  bool
	// TODO:	Dead       bool
	Pid        int
	ExitCode   int
	Error      string
	StartedAt  string
	FinishedAt string
}

ContainerState is from https://github.com/moby/moby/blob/v20.10.1/api/types/types.go#L313-L326

type DNSSettings added in v2.0.4

type DNSSettings struct {
	DNSServers           []string
	DNSResolvConfOptions []string
	DNSSearchDomains     []string
}

type DefaultNetworkSettings

type DefaultNetworkSettings struct {
	// TODO EndpointID          string // EndpointID uniquely represents a service endpoint in a Sandbox
	// TODO Gateway             string // Gateway holds the gateway address for the network
	GlobalIPv6Address   string // GlobalIPv6Address holds network's global IPv6 address
	GlobalIPv6PrefixLen int    // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
	IPAddress           string // IPAddress holds the IPv4 address for the network
	IPPrefixLen         int    // IPPrefixLen represents mask length of network's IPv4 address
	// TODO IPv6Gateway         string // IPv6Gateway holds gateway address specific for IPv6
	MacAddress string // MacAddress holds the MAC address for the network
}

DefaultNetworkSettings is from https://github.com/moby/moby/blob/v20.10.1/api/types/types.go#L405-L414

type DeviceMapping added in v2.0.4

type DeviceMapping struct {
	PathOnHost        string
	PathInContainer   string
	CgroupPermissions string
}

type EndpointResource added in v2.0.5

type EndpointResource struct {
	Name string `json:"Name"`
}

type GraphDriverData

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

From: https://github.com/moby/moby/blob/v26.1.2/api/types/graph_driver_data.go

type HostConfig added in v2.0.4

type HostConfig struct {
	// Binds           []string      // List of volume bindings for this container
	ContainerIDFile string          // File (path) where the containerId is written
	LogConfig       loggerLogConfig // Configuration of the logs for this container
	// NetworkMode     NetworkMode   // Network mode to use for the container
	PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host

	CgroupnsMode string   // Cgroup namespace mode to use for the container
	DNS          []string `json:"Dns"`        // List of DNS server to lookup
	DNSOptions   []string `json:"DnsOptions"` // List of DNSOption to look for
	DNSSearch    []string `json:"DnsSearch"`  // List of DNSSearch to look for
	ExtraHosts   []string // List of extra hosts
	GroupAdd     []string // GroupAdd specifies additional groups to join
	IpcMode      string   `json:"IpcMode"` // IPC namespace to use for the container
	// Cgroup          CgroupSpec        // Cgroup to use for the container
	OomScoreAdj int    // specifies the tune container’s OOM preferences (-1000 to 1000, rootless: 100 to 1000)
	PidMode     string // PID namespace to use for the container
	// Privileged      bool              // Is the container in privileged mode
	// PublishAllPorts bool              // Should docker publish all exposed port for the container
	ReadonlyRootfs bool // Is the container root filesystem in read-only
	// SecurityOpt     []string          // List of string values to customize labels for MLS systems, such as SELinux.
	Tmpfs   map[string]string `json:"Tmpfs,omitempty"` // List of tmpfs (mounts) used for the container
	UTSMode string            // UTS namespace to use for the container
	// UsernsMode      UsernsMode        // The user namespace to use for the container
	ShmSize            int64             // Size of /dev/shm in bytes. The size must be greater than 0.
	Sysctls            map[string]string // List of Namespaced sysctls used for the container
	Runtime            string            // Runtime to use with this container
	CPUSetMems         string            `json:"CpusetMems"`         // CpusetMems 0-2, 0,1
	CPUSetCPUs         string            `json:"CpusetCpus"`         // CpusetCpus 0-2, 0,1
	CPUQuota           int64             `json:"CpuQuota"`           // CPU CFS (Completely Fair Scheduler) quota
	CPUShares          uint64            `json:"CpuShares"`          // CPU shares (relative weight vs. other containers)
	CPUPeriod          uint64            `json:"CpuPeriod"`          // Limits the CPU CFS (Completely Fair Scheduler) period
	CPURealtimePeriod  uint64            `json:"CpuRealtimePeriod"`  // Limits the CPU real-time period in microseconds
	CPURealtimeRuntime int64             `json:"CpuRealtimeRuntime"` // Limits the CPU real-time runtime in microseconds
	Memory             int64             // Memory limit (in bytes)
	MemorySwap         int64             // Total memory usage (memory + swap); set `-1` to enable unlimited swap
	OomKillDisable     bool              // specifies whether to disable OOM Killer
	Devices            []DeviceMapping   // List of devices to map inside the container
	LinuxBlkioSettings
}

From https://github.com/moby/moby/blob/8dbd90ec00daa26dc45d7da2431c965dec99e8b4/api/types/container/host_config.go#L391 HostConfig the non-portable Config structure of a container.

type HostConfigLabel added in v2.0.4

type HostConfigLabel struct {
	BlkioWeight uint16
	CidFile     string
	Devices     []DeviceMapping
}

type IPAM

type IPAM struct {
	// Driver is omitted
	Config []IPAMConfig `json:"Config,omitempty"`
}

type IPAMConfig

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

type Image

type Image struct {
	ID            string `json:"Id"`
	RepoTags      []string
	RepoDigests   []string
	Parent        string
	Comment       string
	Created       string
	DockerVersion string
	Author        string
	Config        *Config
	Architecture  string
	Variant       string `json:",omitempty"`
	Os            string

	Size        int64 // Size is the unpacked size of the image
	VirtualSize int64 `json:"VirtualSize,omitempty"` // Deprecated

	RootFS   RootFS
	Metadata ImageMetadata
}

From https://github.com/moby/moby/blob/v26.1.2/api/types/types.go#L34-L140

func ImageFromNative

func ImageFromNative(nativeImage *native.Image) (*Image, error)

type ImageMetadata

type ImageMetadata struct {
	LastTagTime time.Time `json:",omitempty"`
}

type Info

type Info struct {
	ID          string
	Driver      string
	Plugins     PluginsInfo
	MemoryLimit bool
	SwapLimit   bool
	// KernelMemory is omitted because it is deprecated in the Moby
	CPUCfsPeriod      bool `json:"CpuCfsPeriod"`
	CPUCfsQuota       bool `json:"CpuCfsQuota"`
	CPUShares         bool
	CPUSet            bool
	CPURealtime       bool
	PidsLimit         bool
	IPv4Forwarding    bool
	BridgeNfIptables  bool
	BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
	// Nfd is omitted because it does not make sense for nerdctl
	OomKillDisable bool
	// NGoroutines is omitted because it does not make sense for nerdctl
	SystemTime    string
	LoggingDriver string
	CgroupDriver  string
	CgroupVersion string `json:",omitempty"`
	// NEventsListener is omitted because it does not make sense for nerdctl
	KernelVersion   string
	OperatingSystem string
	OSType          string
	Architecture    string // e.g., "x86_64", not "amd64" (Corresponds to Docker)
	NCPU            int
	MemTotal        int64
	Name            string
	ServerVersion   string
	SecurityOptions []string

	Warnings []string
}

Info mimics a `docker info` object. From https://github.com/moby/moby/blob/v20.10.8/api/types/types.go#L146-L216

type LinuxBlkioSettings added in v2.0.4

type LinuxBlkioSettings struct {
	BlkioWeight          uint16 // Block IO weight (relative weight vs. other containers)
	BlkioWeightDevice    []*specs.LinuxWeightDevice
	BlkioDeviceReadBps   []*specs.LinuxThrottleDevice
	BlkioDeviceWriteBps  []*specs.LinuxThrottleDevice
	BlkioDeviceReadIOps  []*specs.LinuxThrottleDevice
	BlkioDeviceWriteIOps []*specs.LinuxThrottleDevice
}

type MemorySetting added in v2.0.4

type MemorySetting struct {
	Limit            int64 `json:"limit"`
	Swap             int64 `json:"swap"`
	DisableOOMKiller bool  `json:"disableOOMKiller"`
}

type MountPoint

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

From https://github.com/moby/moby/blob/v20.10.1/api/types/types.go#L416-L427 MountPoint represents a mount point configuration inside the container. This is used for reporting the mountpoints in use by a container.

type Network

type Network struct {
	Name       string                      `json:"Name"`
	ID         string                      `json:"Id,omitempty"` // optional in nerdctl
	IPAM       IPAM                        `json:"IPAM,omitempty"`
	Labels     map[string]string           `json:"Labels"`
	Containers map[string]EndpointResource `json:"Containers"` // Containers contains endpoints belonging to the network

}

Network mimics a `docker network inspect` object. From https://github.com/moby/moby/blob/v20.10.7/api/types/types.go#L430-L448

func NetworkFromNative

func NetworkFromNative(n *native.Network) (*Network, error)

type NetworkEndpointSettings

type NetworkEndpointSettings struct {
	// Configurations
	// TODO IPAMConfig *EndpointIPAMConfig
	// TODO Links      []string
	// TODO Aliases    []string
	// Operational data
	// TODO NetworkID           string
	// TODO EndpointID          string
	// TODO Gateway             string
	IPAddress   string
	IPPrefixLen int
	// TODO IPv6Gateway         string
	GlobalIPv6Address   string
	GlobalIPv6PrefixLen int
	MacAddress          string
}

NetworkEndpointSettings is from https://github.com/moby/moby/blob/v20.10.1/api/types/network/network.go#L49-L65

type NetworkSettings

type NetworkSettings struct {
	Ports *nat.PortMap
	DefaultNetworkSettings
	Networks map[string]*NetworkEndpointSettings
}

type PluginsInfo

type PluginsInfo struct {
	Log     []string
	Storage []string // nerdctl extension
}

type RootFS

type RootFS struct {
	Type      string
	Layers    []string `json:",omitempty"`
	BaseLayer string   `json:",omitempty"`
}

type ServerVersion

type ServerVersion struct {
	Components []ComponentVersion
}

ServerVersion is from https://github.com/moby/moby/blob/v20.10.8/api/types/types.go#L119-L137

type VersionInfo

type VersionInfo struct {
	Client ClientVersion
	Server *ServerVersion
}

VersionInfo mimics a `docker version` object. From https://github.com/docker/cli/blob/v20.10.8/cli/command/system/version.go#L68-L72

Jump to

Keyboard shortcuts

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