Documentation
¶
Index ¶
- Variables
- func Compare(a, b *Config) bool
- func DecodeContainerConfig(src io.Reader) (*Config, *HostConfig, error)
- func Merge(userConf, imageConf *Config) error
- func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSet, error)
- type CapList
- type Command
- type Config
- type ContainerConfigWrapper
- type DeviceMapping
- type Entrypoint
- type ExecConfig
- type HostConfig
- type IpcMode
- type KeyValuePair
- type LogConfig
- type LxcConfig
- type NetworkMode
- type PidMode
- type RestartPolicy
- type UTSMode
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConflictContainerNetworkAndLinks conflict between --net=container and links ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior") // ErrConflictNetworkAndDNS conflict between --dns and the network mode ErrConflictNetworkAndDNS = fmt.Errorf("Conflicting options: --dns and the network mode (--net)") // ErrConflictNetworkHostname conflict between the hostname and the network mode ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)") // ErrConflictHostNetworkAndLinks conflict between --net=host and links ErrConflictHostNetworkAndLinks = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior") // ErrConflictContainerNetworkAndMac conflict between the mac address and the network mode ErrConflictContainerNetworkAndMac = fmt.Errorf("Conflicting options: --mac-address and the network mode (--net)") // ErrConflictNetworkHosts conflict between add-host and the network mode ErrConflictNetworkHosts = fmt.Errorf("Conflicting options: --add-host and the network mode (--net)") // ErrConflictNetworkPublishPorts conflict between the pulbish options and the network mode ErrConflictNetworkPublishPorts = fmt.Errorf("Conflicting options: -p, -P, --publish-all, --publish and the network mode (--net)") // ErrConflictNetworkExposePorts conflict between the expose option and the network mode ErrConflictNetworkExposePorts = fmt.Errorf("Conflicting options: --expose and the network mode (--expose)") )
Functions ¶
func Compare ¶
Compare two Config struct. Do not compare the "Image" nor "Hostname" fields If OpenStdin is set, then it differs
func DecodeContainerConfig ¶ added in v0.3.1
func DecodeContainerConfig(src io.Reader) (*Config, *HostConfig, error)
DecodeContainerConfig decodes a json encoded config into a ContainerConfigWrapper struct and returns both a Config and an HostConfig struct Be aware this function is not checking whether the resulted structs are nil, it's your business to do so
func Merge ¶
Merge merges two Config, the image container configuration (defaults values), and the user container configuration, either passed by the API or generated by the cli. It will mutate the specified user configuration (userConf) with the image configuration where the user configuration is incomplete.
func Parse ¶
Parse parses the specified args for the specified command and generates a Config, a HostConfig and returns them with the specified command. If the specified args are not valid, it will return an error.
Types ¶
type CapList ¶ added in v0.4.0
type CapList struct {
// contains filtered or unexported fields
}
CapList represents the list of capabilities of the container.
func NewCapList ¶ added in v0.4.0
NewCapList creates a CapList from a slice of string.
func (*CapList) Len ¶ added in v0.4.0
Len returns the number of specific kernel capabilities.
func (*CapList) MarshalJSON ¶ added in v0.4.0
MarshalJSON marshals (or serializes) the CapList into JSON.
func (*CapList) Slice ¶ added in v0.4.0
Slice returns the specific capabilities into a slice of KeyValuePair.
type Command ¶ added in v0.3.1
type Command struct {
// contains filtered or unexported fields
}
Command encapsulates the container command. It might be represented as a string or an array of strings. We need to override the json decoder to accept both options. The JSON decoder will fail if the api sends an string and
we try to decode it into an array of string.
func NewCommand ¶ added in v0.3.1
NewCommand creates a Command based on the specified parts (as strings).
func (*Command) Len ¶ added in v0.3.1
Len returns the number of parts of the Entrypoint.
func (*Command) MarshalJSON ¶ added in v0.3.1
MarshalJSON Marshals (or serializes) the Command into the json format. This method is needed to implement json.Marshaller.
func (*Command) Slice ¶ added in v0.3.1
Slice gets the parts of the Entrypoint as a Slice of string.
func (*Command) ToString ¶ added in v0.3.2
ToString gets a string representing a Command.
type Config ¶
type Config struct { Hostname string // Hostname Domainname string // Domainname User string // User that will run the command(s) inside the container AttachStdin bool // Attach the standard input, makes possible user interaction AttachStdout bool // Attach the standard output AttachStderr bool // Attach the standard error ExposedPorts map[nat.Port]struct{} // List of exposed ports PublishService string // Name of the network service exposed by the container Tty bool // Attach standard streams to a tty, including stdin if it is not closed. OpenStdin bool // Open stdin StdinOnce bool // If true, close stdin after the 1 attached client disconnects. Env []string // List of environment variable to set in the container Cmd *Command // Command to run when starting the container Image string // Name of the image as it was passed by the operator (eg. could be symbolic) Volumes map[string]struct{} // List of volumes (mounts) used for the container VolumeDriver string // Name of the volume driver used to mount volumes WorkingDir string // Current directory (PWD) in the command will be launched Entrypoint *Entrypoint // Entrypoint to run when starting the container NetworkDisabled bool // Is network disabled MacAddress string // Mac Address of the container OnBuild []string // ONBUILD metadata that were defined on the image Dockerfile Labels map[string]string // List of labels set to this container }
Config contains the configuration data about a container. It should hold only portable information about the container. Here, "portable" means "independent from the host we are running on". Non-portable information *should* appear in HostConfig.
type ContainerConfigWrapper ¶ added in v0.3.1
type ContainerConfigWrapper struct { *Config InnerHostConfig *HostConfig `json:"HostConfig,omitempty"` Cpuset string `json:",omitempty"` // Deprecated. Exported for backwards compatibility. *HostConfig // Deprecated. Exported to read attrubutes from json that are not in the inner host config structure. }
ContainerConfigWrapper is a Config wrapper that hold the container Config (portable) and the corresponding HostConfig (non-portable).
func MergeConfigs ¶
func MergeConfigs(config *Config, hostConfig *HostConfig) *ContainerConfigWrapper
MergeConfigs merges the specified container Config and HostConfig. It creates a ContainerConfigWrapper.
func (*ContainerConfigWrapper) GetHostConfig ¶ added in v0.3.1
func (w *ContainerConfigWrapper) GetHostConfig() *HostConfig
GetHostConfig gets the HostConfig of the Config. It's mostly there to handle Deprecated fields of the ContainerConfigWrapper
type DeviceMapping ¶
DeviceMapping represents the device mapping between the host and the container.
func ParseDevice ¶
func ParseDevice(device string) (DeviceMapping, error)
ParseDevice parses a device mapping string to a DeviceMapping struct
type Entrypoint ¶ added in v0.3.1
type Entrypoint struct {
// contains filtered or unexported fields
}
Entrypoint encapsulates the container entrypoint. It might be represented as a string or an array of strings. We need to override the json decoder to accept both options. The JSON decoder will fail if the api sends an string and
we try to decode it into an array of string.
func NewEntrypoint ¶ added in v0.3.1
func NewEntrypoint(parts ...string) *Entrypoint
NewEntrypoint creates an Entrypoint based on the specified parts (as strings).
func (*Entrypoint) Len ¶ added in v0.3.1
func (e *Entrypoint) Len() int
Len returns the number of parts of the Entrypoint.
func (*Entrypoint) MarshalJSON ¶ added in v0.3.1
func (e *Entrypoint) MarshalJSON() ([]byte, error)
MarshalJSON Marshals (or serializes) the Entrypoint into the json format. This method is needed to implement json.Marshaller.
func (*Entrypoint) Slice ¶ added in v0.3.1
func (e *Entrypoint) Slice() []string
Slice gets the parts of the Entrypoint as a Slice of string.
func (*Entrypoint) UnmarshalJSON ¶ added in v0.3.1
func (e *Entrypoint) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes the entrypoint whether it's a string or an array of strings. This method is needed to implement json.Unmarshaler.
type ExecConfig ¶
type ExecConfig struct { User string // User that will run the command Privileged bool // Is the container in privileged mode Tty bool // Attach standard streams to a tty. Container string // Name of the container (to execute in) AttachStdin bool // Attach the standard input, makes possible user interaction AttachStderr bool // Attach the standard output AttachStdout bool // Attach the standard error Detach bool // Execute in detach mode Cmd []string // Execution commands and args }
ExecConfig is a small subset of the Config struct that hold the configuration for the exec feature of docker.
type HostConfig ¶
type HostConfig struct { Binds []string // List of volume bindings for this container ContainerIDFile string // File (path) where the containerId is written LxcConf *LxcConfig // Additional lxc configuration Memory int64 // Memory limit (in bytes) MemorySwap int64 // Total memory usage (memory + swap); set `-1` to disable swap CPUPeriod int64 `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period CpusetCpus string // CpusetCpus 0-2, 0,1 CpusetMems string // CpusetMems 0-2, 0,1 CPUQuota int64 `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota BlkioWeight int64 // Block IO weight (relative weight vs. other containers) OomKillDisable bool // Whether to disable OOM Killer or not MemorySwappiness *int64 // Tuning container memory swappiness behaviour Privileged bool // Is the container in privileged mode PortBindings nat.PortMap // Port mapping between the exposed port (container) and the host Links []string // List of links (in the name:alias form) PublishAllPorts bool // Should docker publish all exposed port for the container DNS []string `json:"Dns"` // List of DNS server to lookup DNSSearch []string `json:"DnsSearch"` // List of DNSSearch to look for ExtraHosts []string // List of extra hosts VolumesFrom []string // List of volumes to take from other container Devices []DeviceMapping // List of devices to map inside the container NetworkMode NetworkMode // Network namespace to use for the container IpcMode IpcMode // IPC namespace to use for the container PidMode PidMode // PID namespace to use for the container UTSMode UTSMode // UTS namespace to use for the container CapAdd *CapList // List of kernel capabilities to add to the container CapDrop *CapList // List of kernel capabilities to remove from the container GroupAdd []string // List of additional groups that the container process will run as RestartPolicy RestartPolicy // Restart policy to be used for the container SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. ReadonlyRootfs bool // Is the container root filesystem in read-only Ulimits []*ulimit.Ulimit // List of ulimits to be set in the container LogConfig LogConfig // Configuration of the logs for this container CgroupParent string // Parent cgroup. ConsoleSize [2]int // Initial console size on Windows }
HostConfig the non-portable Config structure of a container. Here, "non-portable" means "dependent of the host we are running on". Portable information *should* appear in Config.
func DecodeHostConfig ¶ added in v0.3.1
func DecodeHostConfig(src io.Reader) (*HostConfig, error)
DecodeHostConfig creates a HostConfig based on the specified Reader. It assumes the content of the reader will be JSON, and decodes it.
type IpcMode ¶
type IpcMode string
IpcMode represents the container ipc stack.
func (IpcMode) Container ¶
Container returns the name of the container ipc stack is going to be used.
func (IpcMode) IsContainer ¶
IsContainer indicates whether the container uses a container's ipc stack.
func (IpcMode) IsHost ¶
IsHost indicates whether the container uses the host's ipc stack.
func (IpcMode) IsPrivate ¶
IsPrivate indicates whether the container uses it's private ipc stack.
type KeyValuePair ¶ added in v0.3.1
KeyValuePair is a structure that hold a value for a key.
type LogConfig ¶ added in v0.3.0
LogConfig represents the logging configuration of the container.
type LxcConfig ¶ added in v0.3.1
type LxcConfig struct {
// contains filtered or unexported fields
}
LxcConfig represents the specific LXC configuration of the container.
func NewLxcConfig ¶ added in v0.3.1
func NewLxcConfig(values []KeyValuePair) *LxcConfig
NewLxcConfig creates a LxcConfig from the specified slice of KeyValuePair.
func (*LxcConfig) Len ¶ added in v0.3.1
Len returns the number of specific lxc configuration.
func (*LxcConfig) MarshalJSON ¶ added in v0.3.1
MarshalJSON marshals (or serializes) the LxcConfig into JSON.
func (*LxcConfig) Slice ¶ added in v0.3.1
func (c *LxcConfig) Slice() []KeyValuePair
Slice returns the specific lxc configuration into a slice of KeyValuePair.
type NetworkMode ¶
type NetworkMode string
NetworkMode represents the container network stack.
func DefaultDaemonNetworkMode ¶ added in v0.4.0
func DefaultDaemonNetworkMode() NetworkMode
DefaultDaemonNetworkMode returns the default network stack the daemon should use.
func (NetworkMode) IsBridge ¶ added in v0.3.2
func (n NetworkMode) IsBridge() bool
IsBridge indicates whether container uses the bridge network stack
func (NetworkMode) IsContainer ¶
func (n NetworkMode) IsContainer() bool
IsContainer indicates whether container uses a container network stack.
func (NetworkMode) IsDefault ¶ added in v0.4.0
func (n NetworkMode) IsDefault() bool
IsDefault indicates whether container uses the default network stack.
func (NetworkMode) IsHost ¶
func (n NetworkMode) IsHost() bool
IsHost indicates whether container uses the host network stack.
func (NetworkMode) IsNone ¶
func (n NetworkMode) IsNone() bool
IsNone indicates whether container isn't using a network stack.
func (NetworkMode) IsPrivate ¶
func (n NetworkMode) IsPrivate() bool
IsPrivate indicates whether container uses it's private network stack.
func (NetworkMode) NetworkName ¶ added in v0.4.0
func (n NetworkMode) NetworkName() string
NetworkName returns the name of the network stack.
type PidMode ¶
type PidMode string
PidMode represents the pid stack of the container.
func (PidMode) IsHost ¶
IsHost indicates whether the container uses the host's pid stack.
func (PidMode) IsPrivate ¶
IsPrivate indicates whether the container uses it's private pid stack.
type RestartPolicy ¶
RestartPolicy represents the restart policies of the container.
func ParseRestartPolicy ¶ added in v0.3.1
func ParseRestartPolicy(policy string) (RestartPolicy, error)
ParseRestartPolicy returns the parsed policy or an error indicating what is incorrect
func (*RestartPolicy) IsAlways ¶ added in v0.3.2
func (rp *RestartPolicy) IsAlways() bool
IsAlways indicates whether the container has the "always" restart policy. This means the container will automatically restart regardless of the exit status.
func (*RestartPolicy) IsNone ¶ added in v0.3.2
func (rp *RestartPolicy) IsNone() bool
IsNone indicates whether the container has the "no" restart policy. This means the container will not automatically restart when exiting.
func (*RestartPolicy) IsOnFailure ¶ added in v0.3.2
func (rp *RestartPolicy) IsOnFailure() bool
IsOnFailure indicates whether the container has the "on-failure" restart policy. This means the contain will automatically restart of exiting with a non-zero exit status.
type UTSMode ¶ added in v0.3.2
type UTSMode string
UTSMode represents the UTS namespace of the container.
func (UTSMode) IsHost ¶ added in v0.3.2
IsHost indicates whether the container uses the host's UTS namespace.
func (UTSMode) IsPrivate ¶ added in v0.3.2
IsPrivate indicates whether the container uses it's private UTS namespace.