1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

remove fl prefix in containerOptions

Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
allencloud 2016-08-10 20:32:50 +08:00
parent 2a540c18b6
commit 8ed657d09e

View file

@ -22,88 +22,87 @@ import (
) )
// ContainerOptions is a data object with all the options for creating a container // ContainerOptions is a data object with all the options for creating a container
// TODO: remove fl prefix
type ContainerOptions struct { type ContainerOptions struct {
flAttach opts.ListOpts attach opts.ListOpts
flVolumes opts.ListOpts volumes opts.ListOpts
flTmpfs opts.ListOpts tmpfs opts.ListOpts
flBlkioWeightDevice WeightdeviceOpt blkioWeightDevice WeightdeviceOpt
flDeviceReadBps ThrottledeviceOpt deviceReadBps ThrottledeviceOpt
flDeviceWriteBps ThrottledeviceOpt deviceWriteBps ThrottledeviceOpt
flLinks opts.ListOpts links opts.ListOpts
flAliases opts.ListOpts aliases opts.ListOpts
flLinkLocalIPs opts.ListOpts linkLocalIPs opts.ListOpts
flDeviceReadIOps ThrottledeviceOpt deviceReadIOps ThrottledeviceOpt
flDeviceWriteIOps ThrottledeviceOpt deviceWriteIOps ThrottledeviceOpt
flEnv opts.ListOpts env opts.ListOpts
flLabels opts.ListOpts labels opts.ListOpts
flDevices opts.ListOpts devices opts.ListOpts
flUlimits *UlimitOpt ulimits *UlimitOpt
flSysctls *opts.MapOpts sysctls *opts.MapOpts
flPublish opts.ListOpts publish opts.ListOpts
flExpose opts.ListOpts expose opts.ListOpts
flDNS opts.ListOpts dns opts.ListOpts
flDNSSearch opts.ListOpts dnsSearch opts.ListOpts
flDNSOptions opts.ListOpts dnsOptions opts.ListOpts
flExtraHosts opts.ListOpts extraHosts opts.ListOpts
flVolumesFrom opts.ListOpts volumesFrom opts.ListOpts
flEnvFile opts.ListOpts envFile opts.ListOpts
flCapAdd opts.ListOpts capAdd opts.ListOpts
flCapDrop opts.ListOpts capDrop opts.ListOpts
flGroupAdd opts.ListOpts groupAdd opts.ListOpts
flSecurityOpt opts.ListOpts securityOpt opts.ListOpts
flStorageOpt opts.ListOpts storageOpt opts.ListOpts
flLabelsFile opts.ListOpts labelsFile opts.ListOpts
flLoggingOpts opts.ListOpts loggingOpts opts.ListOpts
flPrivileged bool privileged bool
flPidMode string pidMode string
flUTSMode string utsMode string
flUsernsMode string usernsMode string
flPublishAll bool publishAll bool
flStdin bool stdin bool
flTty bool tty bool
flOomKillDisable bool oomKillDisable bool
flOomScoreAdj int oomScoreAdj int
flContainerIDFile string containerIDFile string
flEntrypoint string entrypoint string
flHostname string hostname string
flMemoryString string memoryString string
flMemoryReservation string memoryReservation string
flMemorySwap string memorySwap string
flKernelMemory string kernelMemory string
flUser string user string
flWorkingDir string workingDir string
flCPUShares int64 cpuShares int64
flCPUPercent int64 cpuPercent int64
flCPUPeriod int64 cpuPeriod int64
flCPUQuota int64 cpuQuota int64
flCpusetCpus string cpusetCpus string
flCpusetMems string cpusetMems string
flBlkioWeight uint16 blkioWeight uint16
flIOMaxBandwidth string ioMaxBandwidth string
flIOMaxIOps uint64 ioMaxIOps uint64
flSwappiness int64 swappiness int64
flNetMode string netMode string
flMacAddress string macAddress string
flIPv4Address string ipv4Address string
flIPv6Address string ipv6Address string
flIpcMode string ipcMode string
flPidsLimit int64 pidsLimit int64
flRestartPolicy string restartPolicy string
flReadonlyRootfs bool readonlyRootfs bool
flLoggingDriver string loggingDriver string
flCgroupParent string cgroupParent string
flVolumeDriver string volumeDriver string
flStopSignal string stopSignal string
flIsolation string isolation string
flShmSize string shmSize string
flNoHealthcheck bool noHealthcheck bool
flHealthCmd string healthCmd string
flHealthInterval time.Duration healthInterval time.Duration
flHealthTimeout time.Duration healthTimeout time.Duration
flHealthRetries int healthRetries int
flRuntime string runtime string
flAutoRemove bool autoRemove bool
Image string Image string
Args []string Args []string
@ -112,138 +111,138 @@ type ContainerOptions struct {
// AddFlags adds all command line flags that will be used by Parse to the FlagSet // AddFlags adds all command line flags that will be used by Parse to the FlagSet
func AddFlags(flags *pflag.FlagSet) *ContainerOptions { func AddFlags(flags *pflag.FlagSet) *ContainerOptions {
copts := &ContainerOptions{ copts := &ContainerOptions{
flAliases: opts.NewListOpts(nil), aliases: opts.NewListOpts(nil),
flAttach: opts.NewListOpts(ValidateAttach), attach: opts.NewListOpts(ValidateAttach),
flBlkioWeightDevice: NewWeightdeviceOpt(ValidateWeightDevice), blkioWeightDevice: NewWeightdeviceOpt(ValidateWeightDevice),
flCapAdd: opts.NewListOpts(nil), capAdd: opts.NewListOpts(nil),
flCapDrop: opts.NewListOpts(nil), capDrop: opts.NewListOpts(nil),
flDNS: opts.NewListOpts(opts.ValidateIPAddress), dns: opts.NewListOpts(opts.ValidateIPAddress),
flDNSOptions: opts.NewListOpts(nil), dnsOptions: opts.NewListOpts(nil),
flDNSSearch: opts.NewListOpts(opts.ValidateDNSSearch), dnsSearch: opts.NewListOpts(opts.ValidateDNSSearch),
flDeviceReadBps: NewThrottledeviceOpt(ValidateThrottleBpsDevice), deviceReadBps: NewThrottledeviceOpt(ValidateThrottleBpsDevice),
flDeviceReadIOps: NewThrottledeviceOpt(ValidateThrottleIOpsDevice), deviceReadIOps: NewThrottledeviceOpt(ValidateThrottleIOpsDevice),
flDeviceWriteBps: NewThrottledeviceOpt(ValidateThrottleBpsDevice), deviceWriteBps: NewThrottledeviceOpt(ValidateThrottleBpsDevice),
flDeviceWriteIOps: NewThrottledeviceOpt(ValidateThrottleIOpsDevice), deviceWriteIOps: NewThrottledeviceOpt(ValidateThrottleIOpsDevice),
flDevices: opts.NewListOpts(ValidateDevice), devices: opts.NewListOpts(ValidateDevice),
flEnv: opts.NewListOpts(ValidateEnv), env: opts.NewListOpts(ValidateEnv),
flEnvFile: opts.NewListOpts(nil), envFile: opts.NewListOpts(nil),
flExpose: opts.NewListOpts(nil), expose: opts.NewListOpts(nil),
flExtraHosts: opts.NewListOpts(ValidateExtraHost), extraHosts: opts.NewListOpts(ValidateExtraHost),
flGroupAdd: opts.NewListOpts(nil), groupAdd: opts.NewListOpts(nil),
flLabels: opts.NewListOpts(ValidateEnv), labels: opts.NewListOpts(ValidateEnv),
flLabelsFile: opts.NewListOpts(nil), labelsFile: opts.NewListOpts(nil),
flLinkLocalIPs: opts.NewListOpts(nil), linkLocalIPs: opts.NewListOpts(nil),
flLinks: opts.NewListOpts(ValidateLink), links: opts.NewListOpts(ValidateLink),
flLoggingOpts: opts.NewListOpts(nil), loggingOpts: opts.NewListOpts(nil),
flPublish: opts.NewListOpts(nil), publish: opts.NewListOpts(nil),
flSecurityOpt: opts.NewListOpts(nil), securityOpt: opts.NewListOpts(nil),
flStorageOpt: opts.NewListOpts(nil), storageOpt: opts.NewListOpts(nil),
flSysctls: opts.NewMapOpts(nil, opts.ValidateSysctl), sysctls: opts.NewMapOpts(nil, opts.ValidateSysctl),
flTmpfs: opts.NewListOpts(nil), tmpfs: opts.NewListOpts(nil),
flUlimits: NewUlimitOpt(nil), ulimits: NewUlimitOpt(nil),
flVolumes: opts.NewListOpts(nil), volumes: opts.NewListOpts(nil),
flVolumesFrom: opts.NewListOpts(nil), volumesFrom: opts.NewListOpts(nil),
} }
// General purpose flags // General purpose flags
flags.VarP(&copts.flAttach, "attach", "a", "Attach to STDIN, STDOUT or STDERR") flags.VarP(&copts.attach, "attach", "a", "Attach to STDIN, STDOUT or STDERR")
flags.Var(&copts.flDevices, "device", "Add a host device to the container") flags.Var(&copts.devices, "device", "Add a host device to the container")
flags.VarP(&copts.flEnv, "env", "e", "Set environment variables") flags.VarP(&copts.env, "env", "e", "Set environment variables")
flags.Var(&copts.flEnvFile, "env-file", "Read in a file of environment variables") flags.Var(&copts.envFile, "env-file", "Read in a file of environment variables")
flags.StringVar(&copts.flEntrypoint, "entrypoint", "", "Overwrite the default ENTRYPOINT of the image") flags.StringVar(&copts.entrypoint, "entrypoint", "", "Overwrite the default ENTRYPOINT of the image")
flags.Var(&copts.flGroupAdd, "group-add", "Add additional groups to join") flags.Var(&copts.groupAdd, "group-add", "Add additional groups to join")
flags.StringVarP(&copts.flHostname, "hostname", "h", "", "Container host name") flags.StringVarP(&copts.hostname, "hostname", "h", "", "Container host name")
flags.BoolVarP(&copts.flStdin, "interactive", "i", false, "Keep STDIN open even if not attached") flags.BoolVarP(&copts.stdin, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.VarP(&copts.flLabels, "label", "l", "Set meta data on a container") flags.VarP(&copts.labels, "label", "l", "Set meta data on a container")
flags.Var(&copts.flLabelsFile, "label-file", "Read in a line delimited file of labels") flags.Var(&copts.labelsFile, "label-file", "Read in a line delimited file of labels")
flags.BoolVar(&copts.flReadonlyRootfs, "read-only", false, "Mount the container's root filesystem as read only") flags.BoolVar(&copts.readonlyRootfs, "read-only", false, "Mount the container's root filesystem as read only")
flags.StringVar(&copts.flRestartPolicy, "restart", "no", "Restart policy to apply when a container exits") flags.StringVar(&copts.restartPolicy, "restart", "no", "Restart policy to apply when a container exits")
flags.StringVar(&copts.flStopSignal, "stop-signal", signal.DefaultStopSignal, fmt.Sprintf("Signal to stop a container, %v by default", signal.DefaultStopSignal)) flags.StringVar(&copts.stopSignal, "stop-signal", signal.DefaultStopSignal, fmt.Sprintf("Signal to stop a container, %v by default", signal.DefaultStopSignal))
flags.Var(copts.flSysctls, "sysctl", "Sysctl options") flags.Var(copts.sysctls, "sysctl", "Sysctl options")
flags.BoolVarP(&copts.flTty, "tty", "t", false, "Allocate a pseudo-TTY") flags.BoolVarP(&copts.tty, "tty", "t", false, "Allocate a pseudo-TTY")
flags.Var(copts.flUlimits, "ulimit", "Ulimit options") flags.Var(copts.ulimits, "ulimit", "Ulimit options")
flags.StringVarP(&copts.flUser, "user", "u", "", "Username or UID (format: <name|uid>[:<group|gid>])") flags.StringVarP(&copts.user, "user", "u", "", "Username or UID (format: <name|uid>[:<group|gid>])")
flags.StringVarP(&copts.flWorkingDir, "workdir", "w", "", "Working directory inside the container") flags.StringVarP(&copts.workingDir, "workdir", "w", "", "Working directory inside the container")
flags.BoolVar(&copts.flAutoRemove, "rm", false, "Automatically remove the container when it exits") flags.BoolVar(&copts.autoRemove, "rm", false, "Automatically remove the container when it exits")
// Security // Security
flags.Var(&copts.flCapAdd, "cap-add", "Add Linux capabilities") flags.Var(&copts.capAdd, "cap-add", "Add Linux capabilities")
flags.Var(&copts.flCapDrop, "cap-drop", "Drop Linux capabilities") flags.Var(&copts.capDrop, "cap-drop", "Drop Linux capabilities")
flags.BoolVar(&copts.flPrivileged, "privileged", false, "Give extended privileges to this container") flags.BoolVar(&copts.privileged, "privileged", false, "Give extended privileges to this container")
flags.Var(&copts.flSecurityOpt, "security-opt", "Security Options") flags.Var(&copts.securityOpt, "security-opt", "Security Options")
flags.StringVar(&copts.flUsernsMode, "userns", "", "User namespace to use") flags.StringVar(&copts.usernsMode, "userns", "", "User namespace to use")
// Network and port publishing flag // Network and port publishing flag
flags.Var(&copts.flExtraHosts, "add-host", "Add a custom host-to-IP mapping (host:ip)") flags.Var(&copts.extraHosts, "add-host", "Add a custom host-to-IP mapping (host:ip)")
flags.Var(&copts.flDNS, "dns", "Set custom DNS servers") flags.Var(&copts.dns, "dns", "Set custom DNS servers")
flags.Var(&copts.flDNSOptions, "dns-opt", "Set DNS options") flags.Var(&copts.dnsOptions, "dns-opt", "Set DNS options")
flags.Var(&copts.flDNSSearch, "dns-search", "Set custom DNS search domains") flags.Var(&copts.dnsSearch, "dns-search", "Set custom DNS search domains")
flags.Var(&copts.flExpose, "expose", "Expose a port or a range of ports") flags.Var(&copts.expose, "expose", "Expose a port or a range of ports")
flags.StringVar(&copts.flIPv4Address, "ip", "", "Container IPv4 address (e.g. 172.30.100.104)") flags.StringVar(&copts.ipv4Address, "ip", "", "Container IPv4 address (e.g. 172.30.100.104)")
flags.StringVar(&copts.flIPv6Address, "ip6", "", "Container IPv6 address (e.g. 2001:db8::33)") flags.StringVar(&copts.ipv6Address, "ip6", "", "Container IPv6 address (e.g. 2001:db8::33)")
flags.Var(&copts.flLinks, "link", "Add link to another container") flags.Var(&copts.links, "link", "Add link to another container")
flags.Var(&copts.flLinkLocalIPs, "link-local-ip", "Container IPv4/IPv6 link-local addresses") flags.Var(&copts.linkLocalIPs, "link-local-ip", "Container IPv4/IPv6 link-local addresses")
flags.StringVar(&copts.flMacAddress, "mac-address", "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)") flags.StringVar(&copts.macAddress, "mac-address", "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)")
flags.VarP(&copts.flPublish, "publish", "p", "Publish a container's port(s) to the host") flags.VarP(&copts.publish, "publish", "p", "Publish a container's port(s) to the host")
flags.BoolVarP(&copts.flPublishAll, "publish-all", "P", false, "Publish all exposed ports to random ports") flags.BoolVarP(&copts.publishAll, "publish-all", "P", false, "Publish all exposed ports to random ports")
// We allow for both "--net" and "--network", although the latter is the recommended way. // We allow for both "--net" and "--network", although the latter is the recommended way.
flags.StringVar(&copts.flNetMode, "net", "default", "Connect a container to a network") flags.StringVar(&copts.netMode, "net", "default", "Connect a container to a network")
flags.StringVar(&copts.flNetMode, "network", "default", "Connect a container to a network") flags.StringVar(&copts.netMode, "network", "default", "Connect a container to a network")
flags.MarkHidden("net") flags.MarkHidden("net")
// We allow for both "--net-alias" and "--network-alias", although the latter is the recommended way. // We allow for both "--net-alias" and "--network-alias", although the latter is the recommended way.
flags.Var(&copts.flAliases, "net-alias", "Add network-scoped alias for the container") flags.Var(&copts.aliases, "net-alias", "Add network-scoped alias for the container")
flags.Var(&copts.flAliases, "network-alias", "Add network-scoped alias for the container") flags.Var(&copts.aliases, "network-alias", "Add network-scoped alias for the container")
flags.MarkHidden("net-alias") flags.MarkHidden("net-alias")
// Logging and storage // Logging and storage
flags.StringVar(&copts.flLoggingDriver, "log-driver", "", "Logging driver for the container") flags.StringVar(&copts.loggingDriver, "log-driver", "", "Logging driver for the container")
flags.StringVar(&copts.flVolumeDriver, "volume-driver", "", "Optional volume driver for the container") flags.StringVar(&copts.volumeDriver, "volume-driver", "", "Optional volume driver for the container")
flags.Var(&copts.flLoggingOpts, "log-opt", "Log driver options") flags.Var(&copts.loggingOpts, "log-opt", "Log driver options")
flags.Var(&copts.flStorageOpt, "storage-opt", "Storage driver options for the container") flags.Var(&copts.storageOpt, "storage-opt", "Storage driver options for the container")
flags.Var(&copts.flTmpfs, "tmpfs", "Mount a tmpfs directory") flags.Var(&copts.tmpfs, "tmpfs", "Mount a tmpfs directory")
flags.Var(&copts.flVolumesFrom, "volumes-from", "Mount volumes from the specified container(s)") flags.Var(&copts.volumesFrom, "volumes-from", "Mount volumes from the specified container(s)")
flags.VarP(&copts.flVolumes, "volume", "v", "Bind mount a volume") flags.VarP(&copts.volumes, "volume", "v", "Bind mount a volume")
// Health-checking // Health-checking
flags.StringVar(&copts.flHealthCmd, "health-cmd", "", "Command to run to check health") flags.StringVar(&copts.healthCmd, "health-cmd", "", "Command to run to check health")
flags.DurationVar(&copts.flHealthInterval, "health-interval", 0, "Time between running the check") flags.DurationVar(&copts.healthInterval, "health-interval", 0, "Time between running the check")
flags.IntVar(&copts.flHealthRetries, "health-retries", 0, "Consecutive failures needed to report unhealthy") flags.IntVar(&copts.healthRetries, "health-retries", 0, "Consecutive failures needed to report unhealthy")
flags.DurationVar(&copts.flHealthTimeout, "health-timeout", 0, "Maximum time to allow one check to run") flags.DurationVar(&copts.healthTimeout, "health-timeout", 0, "Maximum time to allow one check to run")
flags.BoolVar(&copts.flNoHealthcheck, "no-healthcheck", false, "Disable any container-specified HEALTHCHECK") flags.BoolVar(&copts.noHealthcheck, "no-healthcheck", false, "Disable any container-specified HEALTHCHECK")
// Resource management // Resource management
flags.Uint16Var(&copts.flBlkioWeight, "blkio-weight", 0, "Block IO (relative weight), between 10 and 1000") flags.Uint16Var(&copts.blkioWeight, "blkio-weight", 0, "Block IO (relative weight), between 10 and 1000")
flags.Var(&copts.flBlkioWeightDevice, "blkio-weight-device", "Block IO weight (relative device weight)") flags.Var(&copts.blkioWeightDevice, "blkio-weight-device", "Block IO weight (relative device weight)")
flags.StringVar(&copts.flContainerIDFile, "cidfile", "", "Write the container ID to the file") flags.StringVar(&copts.containerIDFile, "cidfile", "", "Write the container ID to the file")
flags.StringVar(&copts.flCpusetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)") flags.StringVar(&copts.cpusetCpus, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
flags.StringVar(&copts.flCpusetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)") flags.StringVar(&copts.cpusetMems, "cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
flags.Int64Var(&copts.flCPUPercent, "cpu-percent", 0, "CPU percent (Windows only)") flags.Int64Var(&copts.cpuPercent, "cpu-percent", 0, "CPU percent (Windows only)")
flags.Int64Var(&copts.flCPUPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period") flags.Int64Var(&copts.cpuPeriod, "cpu-period", 0, "Limit CPU CFS (Completely Fair Scheduler) period")
flags.Int64Var(&copts.flCPUQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota") flags.Int64Var(&copts.cpuQuota, "cpu-quota", 0, "Limit CPU CFS (Completely Fair Scheduler) quota")
flags.Int64VarP(&copts.flCPUShares, "cpu-shares", "c", 0, "CPU shares (relative weight)") flags.Int64VarP(&copts.cpuShares, "cpu-shares", "c", 0, "CPU shares (relative weight)")
flags.Var(&copts.flDeviceReadBps, "device-read-bps", "Limit read rate (bytes per second) from a device") flags.Var(&copts.deviceReadBps, "device-read-bps", "Limit read rate (bytes per second) from a device")
flags.Var(&copts.flDeviceReadIOps, "device-read-iops", "Limit read rate (IO per second) from a device") flags.Var(&copts.deviceReadIOps, "device-read-iops", "Limit read rate (IO per second) from a device")
flags.Var(&copts.flDeviceWriteBps, "device-write-bps", "Limit write rate (bytes per second) to a device") flags.Var(&copts.deviceWriteBps, "device-write-bps", "Limit write rate (bytes per second) to a device")
flags.Var(&copts.flDeviceWriteIOps, "device-write-iops", "Limit write rate (IO per second) to a device") flags.Var(&copts.deviceWriteIOps, "device-write-iops", "Limit write rate (IO per second) to a device")
flags.StringVar(&copts.flIOMaxBandwidth, "io-maxbandwidth", "", "Maximum IO bandwidth limit for the system drive (Windows only)") flags.StringVar(&copts.ioMaxBandwidth, "io-maxbandwidth", "", "Maximum IO bandwidth limit for the system drive (Windows only)")
flags.Uint64Var(&copts.flIOMaxIOps, "io-maxiops", 0, "Maximum IOps limit for the system drive (Windows only)") flags.Uint64Var(&copts.ioMaxIOps, "io-maxiops", 0, "Maximum IOps limit for the system drive (Windows only)")
flags.StringVar(&copts.flKernelMemory, "kernel-memory", "", "Kernel memory limit") flags.StringVar(&copts.kernelMemory, "kernel-memory", "", "Kernel memory limit")
flags.StringVarP(&copts.flMemoryString, "memory", "m", "", "Memory limit") flags.StringVarP(&copts.memoryString, "memory", "m", "", "Memory limit")
flags.StringVar(&copts.flMemoryReservation, "memory-reservation", "", "Memory soft limit") flags.StringVar(&copts.memoryReservation, "memory-reservation", "", "Memory soft limit")
flags.StringVar(&copts.flMemorySwap, "memory-swap", "", "Swap limit equal to memory plus swap: '-1' to enable unlimited swap") flags.StringVar(&copts.memorySwap, "memory-swap", "", "Swap limit equal to memory plus swap: '-1' to enable unlimited swap")
flags.Int64Var(&copts.flSwappiness, "memory-swappiness", -1, "Tune container memory swappiness (0 to 100)") flags.Int64Var(&copts.swappiness, "memory-swappiness", -1, "Tune container memory swappiness (0 to 100)")
flags.BoolVar(&copts.flOomKillDisable, "oom-kill-disable", false, "Disable OOM Killer") flags.BoolVar(&copts.oomKillDisable, "oom-kill-disable", false, "Disable OOM Killer")
flags.IntVar(&copts.flOomScoreAdj, "oom-score-adj", 0, "Tune host's OOM preferences (-1000 to 1000)") flags.IntVar(&copts.oomScoreAdj, "oom-score-adj", 0, "Tune host's OOM preferences (-1000 to 1000)")
flags.Int64Var(&copts.flPidsLimit, "pids-limit", 0, "Tune container pids limit (set -1 for unlimited)") flags.Int64Var(&copts.pidsLimit, "pids-limit", 0, "Tune container pids limit (set -1 for unlimited)")
// Low-level execution (cgroups, namespaces, ...) // Low-level execution (cgroups, namespaces, ...)
flags.StringVar(&copts.flCgroupParent, "cgroup-parent", "", "Optional parent cgroup for the container") flags.StringVar(&copts.cgroupParent, "cgroup-parent", "", "Optional parent cgroup for the container")
flags.StringVar(&copts.flIpcMode, "ipc", "", "IPC namespace to use") flags.StringVar(&copts.ipcMode, "ipc", "", "IPC namespace to use")
flags.StringVar(&copts.flIsolation, "isolation", "", "Container isolation technology") flags.StringVar(&copts.isolation, "isolation", "", "Container isolation technology")
flags.StringVar(&copts.flPidMode, "pid", "", "PID namespace to use") flags.StringVar(&copts.pidMode, "pid", "", "PID namespace to use")
flags.StringVar(&copts.flShmSize, "shm-size", "", "Size of /dev/shm, default value is 64MB") flags.StringVar(&copts.shmSize, "shm-size", "", "Size of /dev/shm, default value is 64MB")
flags.StringVar(&copts.flUTSMode, "uts", "", "UTS namespace to use") flags.StringVar(&copts.utsMode, "uts", "", "UTS namespace to use")
flags.StringVar(&copts.flRuntime, "runtime", "", "Runtime to use for this container") flags.StringVar(&copts.runtime, "runtime", "", "Runtime to use for this container")
return copts return copts
} }
@ -252,72 +251,72 @@ func AddFlags(flags *pflag.FlagSet) *ContainerOptions {
// If the specified args are not valid, it will return an error. // If the specified args are not valid, it will return an error.
func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) { func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *container.HostConfig, *networktypes.NetworkingConfig, error) {
var ( var (
attachStdin = copts.flAttach.Get("stdin") attachStdin = copts.attach.Get("stdin")
attachStdout = copts.flAttach.Get("stdout") attachStdout = copts.attach.Get("stdout")
attachStderr = copts.flAttach.Get("stderr") attachStderr = copts.attach.Get("stderr")
) )
// Validate the input mac address // Validate the input mac address
if copts.flMacAddress != "" { if copts.macAddress != "" {
if _, err := ValidateMACAddress(copts.flMacAddress); err != nil { if _, err := ValidateMACAddress(copts.macAddress); err != nil {
return nil, nil, nil, fmt.Errorf("%s is not a valid mac address", copts.flMacAddress) return nil, nil, nil, fmt.Errorf("%s is not a valid mac address", copts.macAddress)
} }
} }
if copts.flStdin { if copts.stdin {
attachStdin = true attachStdin = true
} }
// If -a is not set, attach to stdout and stderr // If -a is not set, attach to stdout and stderr
if copts.flAttach.Len() == 0 { if copts.attach.Len() == 0 {
attachStdout = true attachStdout = true
attachStderr = true attachStderr = true
} }
var err error var err error
var flMemory int64 var memory int64
if copts.flMemoryString != "" { if copts.memoryString != "" {
flMemory, err = units.RAMInBytes(copts.flMemoryString) memory, err = units.RAMInBytes(copts.memoryString)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
} }
var MemoryReservation int64 var memoryReservation int64
if copts.flMemoryReservation != "" { if copts.memoryReservation != "" {
MemoryReservation, err = units.RAMInBytes(copts.flMemoryReservation) memoryReservation, err = units.RAMInBytes(copts.memoryReservation)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
} }
var memorySwap int64 var memorySwap int64
if copts.flMemorySwap != "" { if copts.memorySwap != "" {
if copts.flMemorySwap == "-1" { if copts.memorySwap == "-1" {
memorySwap = -1 memorySwap = -1
} else { } else {
memorySwap, err = units.RAMInBytes(copts.flMemorySwap) memorySwap, err = units.RAMInBytes(copts.memorySwap)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
} }
} }
var KernelMemory int64 var kernelMemory int64
if copts.flKernelMemory != "" { if copts.kernelMemory != "" {
KernelMemory, err = units.RAMInBytes(copts.flKernelMemory) kernelMemory, err = units.RAMInBytes(copts.kernelMemory)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
} }
swappiness := copts.flSwappiness swappiness := copts.swappiness
if swappiness != -1 && (swappiness < 0 || swappiness > 100) { if swappiness != -1 && (swappiness < 0 || swappiness > 100) {
return nil, nil, nil, fmt.Errorf("invalid value: %d. Valid memory swappiness range is 0-100", swappiness) return nil, nil, nil, fmt.Errorf("invalid value: %d. Valid memory swappiness range is 0-100", swappiness)
} }
var shmSize int64 var shmSize int64
if copts.flShmSize != "" { if copts.shmSize != "" {
shmSize, err = units.RAMInBytes(copts.flShmSize) shmSize, err = units.RAMInBytes(copts.shmSize)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
@ -325,30 +324,30 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
// TODO FIXME units.RAMInBytes should have a uint64 version // TODO FIXME units.RAMInBytes should have a uint64 version
var maxIOBandwidth int64 var maxIOBandwidth int64
if copts.flIOMaxBandwidth != "" { if copts.ioMaxBandwidth != "" {
maxIOBandwidth, err = units.RAMInBytes(copts.flIOMaxBandwidth) maxIOBandwidth, err = units.RAMInBytes(copts.ioMaxBandwidth)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
if maxIOBandwidth < 0 { if maxIOBandwidth < 0 {
return nil, nil, nil, fmt.Errorf("invalid value: %s. Maximum IO Bandwidth must be positive", copts.flIOMaxBandwidth) return nil, nil, nil, fmt.Errorf("invalid value: %s. Maximum IO Bandwidth must be positive", copts.ioMaxBandwidth)
} }
} }
var binds []string var binds []string
// add any bind targets to the list of container volumes // add any bind targets to the list of container volumes
for bind := range copts.flVolumes.GetMap() { for bind := range copts.volumes.GetMap() {
if arr := volumeSplitN(bind, 2); len(arr) > 1 { if arr := volumeSplitN(bind, 2); len(arr) > 1 {
// after creating the bind mount we want to delete it from the copts.flVolumes values because // after creating the bind mount we want to delete it from the copts.volumes values because
// we do not want bind mounts being committed to image configs // we do not want bind mounts being committed to image configs
binds = append(binds, bind) binds = append(binds, bind)
copts.flVolumes.Delete(bind) copts.volumes.Delete(bind)
} }
} }
// Can't evaluate options passed into --tmpfs until we actually mount // Can't evaluate options passed into --tmpfs until we actually mount
tmpfs := make(map[string]string) tmpfs := make(map[string]string)
for _, t := range copts.flTmpfs.GetAll() { for _, t := range copts.tmpfs.GetAll() {
if arr := strings.SplitN(t, ":", 2); len(arr) > 1 { if arr := strings.SplitN(t, ":", 2); len(arr) > 1 {
if _, _, err := mount.ParseTmpfsOptions(arr[1]); err != nil { if _, _, err := mount.ParseTmpfsOptions(arr[1]); err != nil {
return nil, nil, nil, err return nil, nil, nil, err
@ -363,23 +362,25 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
runCmd strslice.StrSlice runCmd strslice.StrSlice
entrypoint strslice.StrSlice entrypoint strslice.StrSlice
) )
if len(copts.Args) > 0 { if len(copts.Args) > 0 {
runCmd = strslice.StrSlice(copts.Args) runCmd = strslice.StrSlice(copts.Args)
} }
if copts.flEntrypoint != "" {
entrypoint = strslice.StrSlice{copts.flEntrypoint} if copts.entrypoint != "" {
entrypoint = strslice.StrSlice{copts.entrypoint}
} else if flags.Changed("entrypoint") { } else if flags.Changed("entrypoint") {
// if `--entrypoint=` is parsed then Entrypoint is reset // if `--entrypoint=` is parsed then Entrypoint is reset
entrypoint = []string{""} entrypoint = []string{""}
} }
ports, portBindings, err := nat.ParsePortSpecs(copts.flPublish.GetAll()) ports, portBindings, err := nat.ParsePortSpecs(copts.publish.GetAll())
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
// Merge in exposed ports to the map of published ports // Merge in exposed ports to the map of published ports
for _, e := range copts.flExpose.GetAll() { for _, e := range copts.expose.GetAll() {
if strings.Contains(e, ":") { if strings.Contains(e, ":") {
return nil, nil, nil, fmt.Errorf("invalid port format for --expose: %s", e) return nil, nil, nil, fmt.Errorf("invalid port format for --expose: %s", e)
} }
@ -404,7 +405,7 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
// parse device mappings // parse device mappings
deviceMappings := []container.DeviceMapping{} deviceMappings := []container.DeviceMapping{}
for _, device := range copts.flDevices.GetAll() { for _, device := range copts.devices.GetAll() {
deviceMapping, err := ParseDevice(device) deviceMapping, err := ParseDevice(device)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
@ -413,64 +414,64 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
} }
// collect all the environment variables for the container // collect all the environment variables for the container
envVariables, err := readKVStrings(copts.flEnvFile.GetAll(), copts.flEnv.GetAll()) envVariables, err := readKVStrings(copts.envFile.GetAll(), copts.env.GetAll())
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
// collect all the labels for the container // collect all the labels for the container
labels, err := readKVStrings(copts.flLabelsFile.GetAll(), copts.flLabels.GetAll()) labels, err := readKVStrings(copts.labelsFile.GetAll(), copts.labels.GetAll())
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
ipcMode := container.IpcMode(copts.flIpcMode) ipcMode := container.IpcMode(copts.ipcMode)
if !ipcMode.Valid() { if !ipcMode.Valid() {
return nil, nil, nil, fmt.Errorf("--ipc: invalid IPC mode") return nil, nil, nil, fmt.Errorf("--ipc: invalid IPC mode")
} }
pidMode := container.PidMode(copts.flPidMode) pidMode := container.PidMode(copts.pidMode)
if !pidMode.Valid() { if !pidMode.Valid() {
return nil, nil, nil, fmt.Errorf("--pid: invalid PID mode") return nil, nil, nil, fmt.Errorf("--pid: invalid PID mode")
} }
utsMode := container.UTSMode(copts.flUTSMode) utsMode := container.UTSMode(copts.utsMode)
if !utsMode.Valid() { if !utsMode.Valid() {
return nil, nil, nil, fmt.Errorf("--uts: invalid UTS mode") return nil, nil, nil, fmt.Errorf("--uts: invalid UTS mode")
} }
usernsMode := container.UsernsMode(copts.flUsernsMode) usernsMode := container.UsernsMode(copts.usernsMode)
if !usernsMode.Valid() { if !usernsMode.Valid() {
return nil, nil, nil, fmt.Errorf("--userns: invalid USER mode") return nil, nil, nil, fmt.Errorf("--userns: invalid USER mode")
} }
restartPolicy, err := ParseRestartPolicy(copts.flRestartPolicy) restartPolicy, err := ParseRestartPolicy(copts.restartPolicy)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
loggingOpts, err := parseLoggingOpts(copts.flLoggingDriver, copts.flLoggingOpts.GetAll()) loggingOpts, err := parseLoggingOpts(copts.loggingDriver, copts.loggingOpts.GetAll())
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
securityOpts, err := parseSecurityOpts(copts.flSecurityOpt.GetAll()) securityOpts, err := parseSecurityOpts(copts.securityOpt.GetAll())
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
storageOpts, err := parseStorageOpts(copts.flStorageOpt.GetAll()) storageOpts, err := parseStorageOpts(copts.storageOpt.GetAll())
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
// Healthcheck // Healthcheck
var healthConfig *container.HealthConfig var healthConfig *container.HealthConfig
haveHealthSettings := copts.flHealthCmd != "" || haveHealthSettings := copts.healthCmd != "" ||
copts.flHealthInterval != 0 || copts.healthInterval != 0 ||
copts.flHealthTimeout != 0 || copts.healthTimeout != 0 ||
copts.flHealthRetries != 0 copts.healthRetries != 0
if copts.flNoHealthcheck { if copts.noHealthcheck {
if haveHealthSettings { if haveHealthSettings {
return nil, nil, nil, fmt.Errorf("--no-healthcheck conflicts with --health-* options") return nil, nil, nil, fmt.Errorf("--no-healthcheck conflicts with --health-* options")
} }
@ -478,118 +479,118 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
healthConfig = &container.HealthConfig{Test: test} healthConfig = &container.HealthConfig{Test: test}
} else if haveHealthSettings { } else if haveHealthSettings {
var probe strslice.StrSlice var probe strslice.StrSlice
if copts.flHealthCmd != "" { if copts.healthCmd != "" {
args := []string{"CMD-SHELL", copts.flHealthCmd} args := []string{"CMD-SHELL", copts.healthCmd}
probe = strslice.StrSlice(args) probe = strslice.StrSlice(args)
} }
if copts.flHealthInterval < 0 { if copts.healthInterval < 0 {
return nil, nil, nil, fmt.Errorf("--health-interval cannot be negative") return nil, nil, nil, fmt.Errorf("--health-interval cannot be negative")
} }
if copts.flHealthTimeout < 0 { if copts.healthTimeout < 0 {
return nil, nil, nil, fmt.Errorf("--health-timeout cannot be negative") return nil, nil, nil, fmt.Errorf("--health-timeout cannot be negative")
} }
healthConfig = &container.HealthConfig{ healthConfig = &container.HealthConfig{
Test: probe, Test: probe,
Interval: copts.flHealthInterval, Interval: copts.healthInterval,
Timeout: copts.flHealthTimeout, Timeout: copts.healthTimeout,
Retries: copts.flHealthRetries, Retries: copts.healthRetries,
} }
} }
resources := container.Resources{ resources := container.Resources{
CgroupParent: copts.flCgroupParent, CgroupParent: copts.cgroupParent,
Memory: flMemory, Memory: memory,
MemoryReservation: MemoryReservation, MemoryReservation: memoryReservation,
MemorySwap: memorySwap, MemorySwap: memorySwap,
MemorySwappiness: &copts.flSwappiness, MemorySwappiness: &copts.swappiness,
KernelMemory: KernelMemory, KernelMemory: kernelMemory,
OomKillDisable: &copts.flOomKillDisable, OomKillDisable: &copts.oomKillDisable,
CPUPercent: copts.flCPUPercent, CPUPercent: copts.cpuPercent,
CPUShares: copts.flCPUShares, CPUShares: copts.cpuShares,
CPUPeriod: copts.flCPUPeriod, CPUPeriod: copts.cpuPeriod,
CpusetCpus: copts.flCpusetCpus, CpusetCpus: copts.cpusetCpus,
CpusetMems: copts.flCpusetMems, CpusetMems: copts.cpusetMems,
CPUQuota: copts.flCPUQuota, CPUQuota: copts.cpuQuota,
PidsLimit: copts.flPidsLimit, PidsLimit: copts.pidsLimit,
BlkioWeight: copts.flBlkioWeight, BlkioWeight: copts.blkioWeight,
BlkioWeightDevice: copts.flBlkioWeightDevice.GetList(), BlkioWeightDevice: copts.blkioWeightDevice.GetList(),
BlkioDeviceReadBps: copts.flDeviceReadBps.GetList(), BlkioDeviceReadBps: copts.deviceReadBps.GetList(),
BlkioDeviceWriteBps: copts.flDeviceWriteBps.GetList(), BlkioDeviceWriteBps: copts.deviceWriteBps.GetList(),
BlkioDeviceReadIOps: copts.flDeviceReadIOps.GetList(), BlkioDeviceReadIOps: copts.deviceReadIOps.GetList(),
BlkioDeviceWriteIOps: copts.flDeviceWriteIOps.GetList(), BlkioDeviceWriteIOps: copts.deviceWriteIOps.GetList(),
IOMaximumIOps: copts.flIOMaxIOps, IOMaximumIOps: copts.ioMaxIOps,
IOMaximumBandwidth: uint64(maxIOBandwidth), IOMaximumBandwidth: uint64(maxIOBandwidth),
Ulimits: copts.flUlimits.GetList(), Ulimits: copts.ulimits.GetList(),
Devices: deviceMappings, Devices: deviceMappings,
} }
config := &container.Config{ config := &container.Config{
Hostname: copts.flHostname, Hostname: copts.hostname,
ExposedPorts: ports, ExposedPorts: ports,
User: copts.flUser, User: copts.user,
Tty: copts.flTty, Tty: copts.tty,
// TODO: deprecated, it comes from -n, --networking // TODO: deprecated, it comes from -n, --networking
// it's still needed internally to set the network to disabled // it's still needed internally to set the network to disabled
// if e.g. bridge is none in daemon opts, and in inspect // if e.g. bridge is none in daemon opts, and in inspect
NetworkDisabled: false, NetworkDisabled: false,
OpenStdin: copts.flStdin, OpenStdin: copts.stdin,
AttachStdin: attachStdin, AttachStdin: attachStdin,
AttachStdout: attachStdout, AttachStdout: attachStdout,
AttachStderr: attachStderr, AttachStderr: attachStderr,
Env: envVariables, Env: envVariables,
Cmd: runCmd, Cmd: runCmd,
Image: copts.Image, Image: copts.Image,
Volumes: copts.flVolumes.GetMap(), Volumes: copts.volumes.GetMap(),
MacAddress: copts.flMacAddress, MacAddress: copts.macAddress,
Entrypoint: entrypoint, Entrypoint: entrypoint,
WorkingDir: copts.flWorkingDir, WorkingDir: copts.workingDir,
Labels: ConvertKVStringsToMap(labels), Labels: ConvertKVStringsToMap(labels),
Healthcheck: healthConfig, Healthcheck: healthConfig,
} }
if flags.Changed("stop-signal") { if flags.Changed("stop-signal") {
config.StopSignal = copts.flStopSignal config.StopSignal = copts.stopSignal
} }
hostConfig := &container.HostConfig{ hostConfig := &container.HostConfig{
Binds: binds, Binds: binds,
ContainerIDFile: copts.flContainerIDFile, ContainerIDFile: copts.containerIDFile,
OomScoreAdj: copts.flOomScoreAdj, OomScoreAdj: copts.oomScoreAdj,
AutoRemove: copts.flAutoRemove, AutoRemove: copts.autoRemove,
Privileged: copts.flPrivileged, Privileged: copts.privileged,
PortBindings: portBindings, PortBindings: portBindings,
Links: copts.flLinks.GetAll(), Links: copts.links.GetAll(),
PublishAllPorts: copts.flPublishAll, PublishAllPorts: copts.publishAll,
// Make sure the dns fields are never nil. // Make sure the dns fields are never nil.
// New containers don't ever have those fields nil, // New containers don't ever have those fields nil,
// but pre created containers can still have those nil values. // but pre created containers can still have those nil values.
// See https://github.com/docker/docker/pull/17779 // See https://github.com/docker/docker/pull/17779
// for a more detailed explanation on why we don't want that. // for a more detailed explanation on why we don't want that.
DNS: copts.flDNS.GetAllOrEmpty(), DNS: copts.dns.GetAllOrEmpty(),
DNSSearch: copts.flDNSSearch.GetAllOrEmpty(), DNSSearch: copts.dnsSearch.GetAllOrEmpty(),
DNSOptions: copts.flDNSOptions.GetAllOrEmpty(), DNSOptions: copts.dnsOptions.GetAllOrEmpty(),
ExtraHosts: copts.flExtraHosts.GetAll(), ExtraHosts: copts.extraHosts.GetAll(),
VolumesFrom: copts.flVolumesFrom.GetAll(), VolumesFrom: copts.volumesFrom.GetAll(),
NetworkMode: container.NetworkMode(copts.flNetMode), NetworkMode: container.NetworkMode(copts.netMode),
IpcMode: ipcMode, IpcMode: ipcMode,
PidMode: pidMode, PidMode: pidMode,
UTSMode: utsMode, UTSMode: utsMode,
UsernsMode: usernsMode, UsernsMode: usernsMode,
CapAdd: strslice.StrSlice(copts.flCapAdd.GetAll()), CapAdd: strslice.StrSlice(copts.capAdd.GetAll()),
CapDrop: strslice.StrSlice(copts.flCapDrop.GetAll()), CapDrop: strslice.StrSlice(copts.capDrop.GetAll()),
GroupAdd: copts.flGroupAdd.GetAll(), GroupAdd: copts.groupAdd.GetAll(),
RestartPolicy: restartPolicy, RestartPolicy: restartPolicy,
SecurityOpt: securityOpts, SecurityOpt: securityOpts,
StorageOpt: storageOpts, StorageOpt: storageOpts,
ReadonlyRootfs: copts.flReadonlyRootfs, ReadonlyRootfs: copts.readonlyRootfs,
LogConfig: container.LogConfig{Type: copts.flLoggingDriver, Config: loggingOpts}, LogConfig: container.LogConfig{Type: copts.loggingDriver, Config: loggingOpts},
VolumeDriver: copts.flVolumeDriver, VolumeDriver: copts.volumeDriver,
Isolation: container.Isolation(copts.flIsolation), Isolation: container.Isolation(copts.isolation),
ShmSize: shmSize, ShmSize: shmSize,
Resources: resources, Resources: resources,
Tmpfs: tmpfs, Tmpfs: tmpfs,
Sysctls: copts.flSysctls.GetAll(), Sysctls: copts.sysctls.GetAll(),
Runtime: copts.flRuntime, Runtime: copts.runtime,
} }
// When allocating stdin in attached mode, close stdin at client disconnect // When allocating stdin in attached mode, close stdin at client disconnect
@ -601,18 +602,18 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
EndpointsConfig: make(map[string]*networktypes.EndpointSettings), EndpointsConfig: make(map[string]*networktypes.EndpointSettings),
} }
if copts.flIPv4Address != "" || copts.flIPv6Address != "" || copts.flLinkLocalIPs.Len() > 0 { if copts.ipv4Address != "" || copts.ipv6Address != "" || copts.linkLocalIPs.Len() > 0 {
epConfig := &networktypes.EndpointSettings{} epConfig := &networktypes.EndpointSettings{}
networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)] = epConfig networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)] = epConfig
epConfig.IPAMConfig = &networktypes.EndpointIPAMConfig{ epConfig.IPAMConfig = &networktypes.EndpointIPAMConfig{
IPv4Address: copts.flIPv4Address, IPv4Address: copts.ipv4Address,
IPv6Address: copts.flIPv6Address, IPv6Address: copts.ipv6Address,
} }
if copts.flLinkLocalIPs.Len() > 0 { if copts.linkLocalIPs.Len() > 0 {
epConfig.IPAMConfig.LinkLocalIPs = make([]string, copts.flLinkLocalIPs.Len()) epConfig.IPAMConfig.LinkLocalIPs = make([]string, copts.linkLocalIPs.Len())
copy(epConfig.IPAMConfig.LinkLocalIPs, copts.flLinkLocalIPs.GetAll()) copy(epConfig.IPAMConfig.LinkLocalIPs, copts.linkLocalIPs.GetAll())
} }
} }
@ -626,13 +627,13 @@ func Parse(flags *pflag.FlagSet, copts *ContainerOptions) (*container.Config, *c
networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)] = epConfig networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)] = epConfig
} }
if copts.flAliases.Len() > 0 { if copts.aliases.Len() > 0 {
epConfig := networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)] epConfig := networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)]
if epConfig == nil { if epConfig == nil {
epConfig = &networktypes.EndpointSettings{} epConfig = &networktypes.EndpointSettings{}
} }
epConfig.Aliases = make([]string, copts.flAliases.Len()) epConfig.Aliases = make([]string, copts.aliases.Len())
copy(epConfig.Aliases, copts.flAliases.GetAll()) copy(epConfig.Aliases, copts.aliases.GetAll())
networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)] = epConfig networkingConfig.EndpointsConfig[string(hostConfig.NetworkMode)] = epConfig
} }