runconfig

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior")
	ErrConflictNetworkAndDns            = fmt.Errorf("Conflicting options: --dns and the network mode (--net)")
	ErrConflictNetworkHostname          = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
	ErrConflictHostNetworkAndLinks      = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior")
	ErrConflictContainerNetworkAndMac   = fmt.Errorf("Conflicting options: --mac-address and the network mode (--net)")
	ErrConflictNetworkHosts             = fmt.Errorf("Conflicting options: --add-host and the network mode (--net)")
	ErrConflictNetworkPublishPorts      = fmt.Errorf("Conflicting options: -p, -P, --publish-all, --publish and the network mode (--net)")
	ErrConflictNetworkExposePorts       = fmt.Errorf("Conflicting options: --expose and the network mode (--expose)")
)

Functions

func Compare

func Compare(a, b *Config) bool

Compare two Config struct. Do not compare the "Image" nor "Hostname" fields If OpenStdin is set, then it differs

func DecodeContainerConfig added in v1.7.0

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

func Merge(userConf, imageConf *Config) error

func Parse

func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSet, error)

Types

type CapList added in v1.8.0

type CapList struct {
	// contains filtered or unexported fields
}

func NewCapList added in v1.8.0

func NewCapList(caps []string) *CapList

func (*CapList) Len added in v1.8.0

func (c *CapList) Len() int

func (*CapList) MarshalJSON added in v1.8.0

func (c *CapList) MarshalJSON() ([]byte, error)

func (*CapList) Slice added in v1.8.0

func (c *CapList) Slice() []string

func (*CapList) UnmarshalJSON added in v1.8.0

func (c *CapList) UnmarshalJSON(b []byte) error

type Command added in v1.7.0

type Command struct {
	// contains filtered or unexported fields
}

func NewCommand added in v1.7.0

func NewCommand(parts ...string) *Command

func (*Command) Len added in v1.7.0

func (e *Command) Len() int

func (*Command) MarshalJSON added in v1.7.0

func (e *Command) MarshalJSON() ([]byte, error)

func (*Command) Slice added in v1.7.0

func (e *Command) Slice() []string

func (*Command) ToString added in v1.7.0

func (e *Command) ToString() string

func (*Command) UnmarshalJSON added in v1.7.0

func (e *Command) UnmarshalJSON(b []byte) error

UnmarshalJSON decoded the entrypoint whether it's a string or an array of strings.

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{} `json:",omitempty"` // List of exposed ports
	PublishService  string                `json:",omitempty"` // 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                `json:",omitempty"` // 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                  `json:",omitempty"` // Is network disabled
	MacAddress      string                `json:",omitempty"` // 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
}

Note: the Config structure 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. All fields added to this struct must be marked `omitempty` to keep getting predictable hashes from the old `v1Compatibility` configuration.

type ContainerConfigWrapper added in v1.7.0

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.

}

func MergeConfigs added in v1.3.0

func MergeConfigs(config *Config, hostConfig *HostConfig) *ContainerConfigWrapper

func (*ContainerConfigWrapper) GetHostConfig added in v1.7.0

func (w *ContainerConfigWrapper) GetHostConfig() *HostConfig

type DeviceMapping added in v1.2.0

type DeviceMapping struct {
	PathOnHost        string
	PathInContainer   string
	CgroupPermissions string
}

func ParseDevice added in v1.2.0

func ParseDevice(device string) (DeviceMapping, error)

type Entrypoint added in v1.7.0

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 v1.7.0

func NewEntrypoint(parts ...string) *Entrypoint

func (*Entrypoint) Len added in v1.7.0

func (e *Entrypoint) Len() int

func (*Entrypoint) MarshalJSON added in v1.7.0

func (e *Entrypoint) MarshalJSON() ([]byte, error)

func (*Entrypoint) Slice added in v1.7.0

func (e *Entrypoint) Slice() []string

func (*Entrypoint) UnmarshalJSON added in v1.7.0

func (e *Entrypoint) UnmarshalJSON(b []byte) error

UnmarshalJSON decoded the entrypoint whether it's a string or an array of strings.

type ExecConfig added in v1.3.0

type ExecConfig struct {
	User         string
	Privileged   bool
	Tty          bool
	Container    string
	AttachStdin  bool
	AttachStderr bool
	AttachStdout bool
	Detach       bool
	Cmd          []string
}

func ParseExec added in v1.3.0

func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error)

type HostConfig

type HostConfig struct {
	Binds            []string
	ContainerIDFile  string
	LxcConf          *LxcConfig
	Memory           int64 // Memory limit (in bytes)
	MemorySwap       int64 // Total memory usage (memory + swap); set `-1` to disable swap
	CpuShares        int64 // CPU shares (relative weight vs. other containers)
	CpuPeriod        int64
	CpusetCpus       string // CpusetCpus 0-2, 0,1
	CpusetMems       string // CpusetMems 0-2, 0,1
	CpuQuota         int64
	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
	PortBindings     nat.PortMap
	Links            []string
	PublishAllPorts  bool
	Dns              []string
	DnsSearch        []string
	ExtraHosts       []string
	VolumesFrom      []string
	Devices          []DeviceMapping
	NetworkMode      NetworkMode
	IpcMode          IpcMode
	PidMode          PidMode
	UTSMode          UTSMode
	CapAdd           *CapList
	CapDrop          *CapList
	GroupAdd         []string
	RestartPolicy    RestartPolicy
	SecurityOpt      []string
	ReadonlyRootfs   bool
	Ulimits          []*ulimit.Ulimit
	LogConfig        LogConfig
	CgroupParent     string // Parent cgroup.
	ConsoleSize      [2]int // Initial console size on Windows
}

func DecodeHostConfig added in v1.7.0

func DecodeHostConfig(src io.Reader) (*HostConfig, error)

type IpcMode added in v1.4.0

type IpcMode string

func (IpcMode) Container added in v1.4.0

func (n IpcMode) Container() string

func (IpcMode) IsContainer added in v1.4.0

func (n IpcMode) IsContainer() bool

func (IpcMode) IsHost added in v1.4.0

func (n IpcMode) IsHost() bool

func (IpcMode) IsPrivate added in v1.4.0

func (n IpcMode) IsPrivate() bool

IsPrivate indicates whether container use it's private ipc stack

func (IpcMode) Valid added in v1.4.0

func (n IpcMode) Valid() bool

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

type LogConfig added in v1.6.0

type LogConfig struct {
	Type   string
	Config map[string]string
}

type LxcConfig added in v1.7.0

type LxcConfig struct {
	// contains filtered or unexported fields
}

func NewLxcConfig added in v1.7.0

func NewLxcConfig(values []KeyValuePair) *LxcConfig

func (*LxcConfig) Len added in v1.7.0

func (c *LxcConfig) Len() int

func (*LxcConfig) MarshalJSON added in v1.7.0

func (c *LxcConfig) MarshalJSON() ([]byte, error)

func (*LxcConfig) Slice added in v1.7.0

func (c *LxcConfig) Slice() []KeyValuePair

func (*LxcConfig) UnmarshalJSON added in v1.7.0

func (c *LxcConfig) UnmarshalJSON(b []byte) error

type NetworkMode added in v0.11.0

type NetworkMode string

func DefaultDaemonNetworkMode added in v1.8.0

func DefaultDaemonNetworkMode() NetworkMode

func (NetworkMode) IsBridge added in v1.7.0

func (n NetworkMode) IsBridge() bool

func (NetworkMode) IsContainer added in v0.11.0

func (n NetworkMode) IsContainer() bool

func (NetworkMode) IsDefault added in v1.8.0

func (n NetworkMode) IsDefault() bool

func (NetworkMode) IsHost added in v0.11.0

func (n NetworkMode) IsHost() bool

func (NetworkMode) IsNone added in v1.3.0

func (n NetworkMode) IsNone() bool

func (NetworkMode) IsPrivate added in v1.3.0

func (n NetworkMode) IsPrivate() bool

IsPrivate indicates whether container use it's private network stack

func (NetworkMode) NetworkName added in v1.8.0

func (n NetworkMode) NetworkName() string

type PidMode added in v1.5.0

type PidMode string

func (PidMode) IsHost added in v1.5.0

func (n PidMode) IsHost() bool

func (PidMode) IsPrivate added in v1.5.0

func (n PidMode) IsPrivate() bool

IsPrivate indicates whether container use it's private pid stack

func (PidMode) Valid added in v1.5.0

func (n PidMode) Valid() bool

type RestartPolicy added in v1.2.0

type RestartPolicy struct {
	Name              string
	MaximumRetryCount int
}

func ParseRestartPolicy added in v1.7.0

func ParseRestartPolicy(policy string) (RestartPolicy, error)

ParseRestartPolicy returns the parsed policy or an error indicating what is incorrect

func (*RestartPolicy) IsAlways added in v1.7.0

func (rp *RestartPolicy) IsAlways() bool

func (*RestartPolicy) IsNone added in v1.7.0

func (rp *RestartPolicy) IsNone() bool

func (*RestartPolicy) IsOnFailure added in v1.7.0

func (rp *RestartPolicy) IsOnFailure() bool

type UTSMode added in v1.7.0

type UTSMode string

func (UTSMode) IsHost added in v1.7.0

func (n UTSMode) IsHost() bool

func (UTSMode) IsPrivate added in v1.7.0

func (n UTSMode) IsPrivate() bool

IsPrivate indicates whether container use it's private UTS namespace

func (UTSMode) Valid added in v1.7.0

func (n UTSMode) Valid() bool

Jump to

Keyboard shortcuts

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