summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/create.go34
-rw-r--r--cmd/podman/common/createparse.go21
-rw-r--r--cmd/podman/common/default.go121
-rw-r--r--cmd/podman/common/netflags.go103
-rw-r--r--cmd/podman/common/specgen.go281
-rw-r--r--cmd/podman/containers/attach.go38
-rw-r--r--cmd/podman/containers/commit.go36
-rw-r--r--cmd/podman/containers/container.go16
-rw-r--r--cmd/podman/containers/cp.go55
-rw-r--r--cmd/podman/containers/create.go32
-rw-r--r--cmd/podman/containers/exec.go39
-rw-r--r--cmd/podman/containers/export.go25
-rw-r--r--cmd/podman/containers/kill.go36
-rw-r--r--cmd/podman/containers/mount.go28
-rw-r--r--cmd/podman/containers/pause.go25
-rw-r--r--cmd/podman/containers/port.go123
-rw-r--r--cmd/podman/containers/restart.go40
-rw-r--r--cmd/podman/containers/rm.go36
-rw-r--r--cmd/podman/containers/run.go37
-rw-r--r--cmd/podman/containers/start.go37
-rw-r--r--cmd/podman/containers/stop.go42
-rw-r--r--cmd/podman/containers/top.go38
-rw-r--r--cmd/podman/containers/unmount.go30
-rw-r--r--cmd/podman/containers/unpause.go26
-rw-r--r--cmd/podman/containers/wait.go37
-rw-r--r--cmd/podman/images/inspect.go8
-rw-r--r--cmd/podman/images/rm.go32
-rw-r--r--cmd/podman/login.go68
-rw-r--r--cmd/podman/logout.go57
-rw-r--r--cmd/podman/pods/create.go5
-rw-r--r--cmd/podman/pods/pod.go2
-rw-r--r--cmd/podman/pods/stop.go3
-rw-r--r--cmd/podman/system/service.go3
-rw-r--r--cmd/podman/system/service_abi.go57
-rw-r--r--cmd/podman/system/service_unsupported.go14
-rw-r--r--cmd/podman/volumes/create.go2
36 files changed, 1168 insertions, 419 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index 49a40dfa0..f256d9677 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -51,12 +51,12 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringVar(
&cf.CGroupsNS,
- "cgroupns", getDefaultCgroupNS(),
+ "cgroupns", containerConfig.CgroupNS(),
"cgroup namespace to use",
)
createFlags.StringVar(
&cf.CGroups,
- "cgroups", "enabled",
+ "cgroups", containerConfig.Cgroups(),
`control container cgroup configuration ("enabled"|"disabled"|"no-conmon")`,
)
createFlags.StringVar(
@@ -121,12 +121,12 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringVar(
&cf.DetachKeys,
- "detach-keys", GetDefaultDetachKeys(),
+ "detach-keys", containerConfig.DetachKeys(),
"Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-cf`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`",
)
createFlags.StringSliceVar(
&cf.Device,
- "device", getDefaultDevices(),
+ "device", containerConfig.Devices(),
fmt.Sprintf("Add a host device to the container"),
)
createFlags.StringSliceVar(
@@ -161,7 +161,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringArrayVarP(
&cf.env,
- "env", "e", getDefaultEnv(),
+ "env", "e", containerConfig.Env(),
"Set environment variables in container",
)
createFlags.BoolVar(
@@ -238,7 +238,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringVar(
&cf.InitPath,
- "init-path", getDefaultInitPath(),
+ "init-path", containerConfig.InitPath(),
// Do not use the Value field for setting the default value to determine user input (i.e., non-empty string)
fmt.Sprintf("Path to the container-init binary"),
)
@@ -249,7 +249,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringVar(
&cf.IPC,
- "ipc", getDefaultIPCNS(),
+ "ipc", containerConfig.IPCNS(),
"IPC namespace to use",
)
createFlags.StringVar(
@@ -331,13 +331,13 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
// markFlagHidden(createFlags, "override-os")
createFlags.StringVar(
&cf.PID,
- "pid", getDefaultPidNS(),
+ "pid", containerConfig.PidNS(),
"PID namespace to use",
)
createFlags.Int64Var(
&cf.PIDsLimit,
- "pids-limit", getDefaultPidsLimit(),
- getDefaultPidsDescription(),
+ "pids-limit", containerConfig.PidsLimit(),
+ "Tune container pids limit (set 0 for unlimited, -1 for server defaults)",
)
createFlags.StringVar(
&cf.Pod,
@@ -391,12 +391,12 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringArrayVar(
&cf.SecurityOpt,
- "security-opt", getDefaultSecurityOptions(),
+ "security-opt", containerConfig.SecurityOptions(),
"Security Options",
)
createFlags.StringVar(
&cf.ShmSize,
- "shm-size", getDefaultShmSize(),
+ "shm-size", containerConfig.ShmSize(),
"Size of /dev/shm "+sizeWithUnitFormat,
)
createFlags.StringVar(
@@ -427,7 +427,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
createFlags.StringSliceVar(
&cf.Sysctl,
- "sysctl", getDefaultSysctls(),
+ "sysctl", containerConfig.Sysctls(),
"Sysctl options",
)
createFlags.StringVar(
@@ -452,7 +452,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringSliceVar(
&cf.Ulimit,
- "ulimit", getDefaultUlimits(),
+ "ulimit", containerConfig.Ulimits(),
"Ulimit options",
)
createFlags.StringVarP(
@@ -462,12 +462,12 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringVar(
&cf.UserNS,
- "userns", getDefaultUserNS(),
+ "userns", containerConfig.Containers.UserNS,
"User namespace to use",
)
createFlags.StringVar(
&cf.UTS,
- "uts", getDefaultUTSNS(),
+ "uts", containerConfig.Containers.UTSNS,
"UTS namespace to use",
)
createFlags.StringArrayVar(
@@ -477,7 +477,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
createFlags.StringArrayVarP(
&cf.Volume,
- "volume", "v", getDefaultVolumes(),
+ "volume", "v", containerConfig.Volumes(),
"Bind mount a volume into the container",
)
createFlags.StringSliceVar(
diff --git a/cmd/podman/common/createparse.go b/cmd/podman/common/createparse.go
index aca6f752e..fe6e322c2 100644
--- a/cmd/podman/common/createparse.go
+++ b/cmd/podman/common/createparse.go
@@ -1,7 +1,6 @@
package common
import (
- "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/pkg/util"
"github.com/pkg/errors"
)
@@ -17,27 +16,7 @@ func (c *ContainerCLIOpts) validate() error {
if _, err := util.ValidatePullType(c.Pull); err != nil {
return err
}
- // Verify the additional hosts are in correct format
- for _, host := range c.Net.AddHosts {
- if _, err := parse.ValidateExtraHost(host); err != nil {
- return err
- }
- }
- if dnsSearches := c.Net.DNSSearch; len(dnsSearches) > 0 {
- // Validate domains are good
- for _, dom := range dnsSearches {
- if dom == "." {
- if len(dnsSearches) > 1 {
- return errors.Errorf("cannot pass additional search domains when also specifying '.'")
- }
- continue
- }
- if _, err := parse.ValidateDomain(dom); err != nil {
- return err
- }
- }
- }
var imageVolType = map[string]string{
"bind": "",
"tmpfs": "",
diff --git a/cmd/podman/common/default.go b/cmd/podman/common/default.go
index 853f87ab6..89316270b 100644
--- a/cmd/podman/common/default.go
+++ b/cmd/podman/common/default.go
@@ -1,18 +1,5 @@
package common
-import (
- "fmt"
- "os"
-
- "github.com/containers/buildah/pkg/parse"
- "github.com/containers/libpod/pkg/apparmor"
- "github.com/containers/libpod/pkg/cgroups"
- "github.com/containers/libpod/pkg/rootless"
- "github.com/containers/libpod/pkg/specgen"
- "github.com/containers/libpod/pkg/sysinfo"
- "github.com/opencontainers/selinux/go-selinux"
-)
-
var (
// DefaultHealthCheckInterval default value
DefaultHealthCheckInterval = "30s"
@@ -25,111 +12,3 @@ var (
// DefaultImageVolume default value
DefaultImageVolume = "bind"
)
-
-// TODO these options are directly embedded into many of the CLI cobra values, as such
-// this approach will not work in a remote client. so we will need to likely do something like a
-// supported and unsupported approach here and backload these options into the specgen
-// once we are "on" the host system.
-func getDefaultSecurityOptions() []string {
- securityOpts := []string{}
- if containerConfig.Containers.SeccompProfile != "" && containerConfig.Containers.SeccompProfile != parse.SeccompDefaultPath {
- securityOpts = append(securityOpts, fmt.Sprintf("seccomp=%s", containerConfig.Containers.SeccompProfile))
- }
- if apparmor.IsEnabled() && containerConfig.Containers.ApparmorProfile != "" {
- securityOpts = append(securityOpts, fmt.Sprintf("apparmor=%s", containerConfig.Containers.ApparmorProfile))
- }
- if selinux.GetEnabled() && !containerConfig.Containers.EnableLabeling {
- securityOpts = append(securityOpts, fmt.Sprintf("label=%s", selinux.DisableSecOpt()[0]))
- }
- return securityOpts
-}
-
-// getDefaultSysctls
-func getDefaultSysctls() []string {
- return containerConfig.Containers.DefaultSysctls
-}
-
-func getDefaultVolumes() []string {
- return containerConfig.Containers.Volumes
-}
-
-func getDefaultDevices() []string {
- return containerConfig.Containers.Devices
-}
-
-func getDefaultDNSServers() []string { //nolint
- return containerConfig.Containers.DNSServers
-}
-
-func getDefaultDNSSearches() []string { //nolint
- return containerConfig.Containers.DNSSearches
-}
-
-func getDefaultDNSOptions() []string { //nolint
- return containerConfig.Containers.DNSOptions
-}
-
-func getDefaultEnv() []string {
- return containerConfig.Containers.Env
-}
-
-func getDefaultInitPath() string {
- return containerConfig.Containers.InitPath
-}
-
-func getDefaultIPCNS() string {
- return containerConfig.Containers.IPCNS
-}
-
-func getDefaultPidNS() string {
- return containerConfig.Containers.PidNS
-}
-
-func getDefaultNetNS() string { //nolint
- if containerConfig.Containers.NetNS == string(specgen.Private) && rootless.IsRootless() {
- return string(specgen.Slirp)
- }
- return containerConfig.Containers.NetNS
-}
-
-func getDefaultCgroupNS() string {
- return containerConfig.Containers.CgroupNS
-}
-
-func getDefaultUTSNS() string {
- return containerConfig.Containers.UTSNS
-}
-
-func getDefaultShmSize() string {
- return containerConfig.Containers.ShmSize
-}
-
-func getDefaultUlimits() []string {
- return containerConfig.Containers.DefaultUlimits
-}
-
-func getDefaultUserNS() string {
- userns := os.Getenv("PODMAN_USERNS")
- if userns != "" {
- return userns
- }
- return containerConfig.Containers.UserNS
-}
-
-func getDefaultPidsLimit() int64 {
- if rootless.IsRootless() {
- cgroup2, _ := cgroups.IsCgroup2UnifiedMode()
- if cgroup2 {
- return containerConfig.Containers.PidsLimit
- }
- }
- return sysinfo.GetDefaultPidsLimit()
-}
-
-func getDefaultPidsDescription() string {
- return "Tune container pids limit (set 0 for unlimited)"
-}
-
-func GetDefaultDetachKeys() string {
- return containerConfig.Engine.DetachKeys
-}
diff --git a/cmd/podman/common/netflags.go b/cmd/podman/common/netflags.go
index 41eed2988..a439eb792 100644
--- a/cmd/podman/common/netflags.go
+++ b/cmd/podman/common/netflags.go
@@ -3,7 +3,10 @@ package common
import (
"net"
+ "github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/specgen"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -15,15 +18,15 @@ func GetNetFlags() *pflag.FlagSet {
"Add a custom host-to-IP mapping (host:ip) (default [])",
)
netFlags.StringSlice(
- "dns", getDefaultDNSServers(),
+ "dns", containerConfig.DNSServers(),
"Set custom DNS servers",
)
netFlags.StringSlice(
- "dns-opt", getDefaultDNSOptions(),
+ "dns-opt", containerConfig.DNSOptions(),
"Set custom DNS options",
)
netFlags.StringSlice(
- "dns-search", getDefaultDNSSearches(),
+ "dns-search", containerConfig.DNSSearches(),
"Set custom DNS search domains",
)
netFlags.String(
@@ -35,7 +38,7 @@ func GetNetFlags() *pflag.FlagSet {
"Container MAC address (e.g. 92:d0:c6:0a:29:33)",
)
netFlags.String(
- "network", getDefaultNetNS(),
+ "network", containerConfig.NetNS(),
"Connect a container to a network",
)
netFlags.StringSliceP(
@@ -58,20 +61,60 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) {
if err != nil {
return nil, err
}
- servers, err := cmd.Flags().GetStringSlice("dns")
- if err != nil {
- return nil, err
+ // Verify the additional hosts are in correct format
+ for _, host := range opts.AddHosts {
+ if _, err := parse.ValidateExtraHost(host); err != nil {
+ return nil, err
+ }
}
- for _, d := range servers {
- if d == "none" {
- opts.DNSHost = true
- break
+
+ if cmd.Flags().Changed("dns") {
+ servers, err := cmd.Flags().GetStringSlice("dns")
+ if err != nil {
+ return nil, err
+ }
+ for _, d := range servers {
+ if d == "none" {
+ opts.UseImageResolvConf = true
+ if len(servers) > 1 {
+ return nil, errors.Errorf("%s is not allowed to be specified with other DNS ip addresses", d)
+ }
+ break
+ }
+ dns := net.ParseIP(d)
+ if dns == nil {
+ return nil, errors.Errorf("%s is not an ip address", d)
+ }
+ opts.DNSServers = append(opts.DNSServers, dns)
}
- opts.DNSServers = append(opts.DNSServers, net.ParseIP(d))
}
- opts.DNSSearch, err = cmd.Flags().GetStringSlice("dns-search")
- if err != nil {
- return nil, err
+
+ if cmd.Flags().Changed("dns-opt") {
+ options, err := cmd.Flags().GetStringSlice("dns-opt")
+ if err != nil {
+ return nil, err
+ }
+ opts.DNSOptions = options
+ }
+
+ if cmd.Flags().Changed("dns-search") {
+ dnsSearches, err := cmd.Flags().GetStringSlice("dns-search")
+ if err != nil {
+ return nil, err
+ }
+ // Validate domains are good
+ for _, dom := range dnsSearches {
+ if dom == "." {
+ if len(dnsSearches) > 1 {
+ return nil, errors.Errorf("cannot pass additional search domains when also specifying '.'")
+ }
+ continue
+ }
+ if _, err := parse.ValidateDomain(dom); err != nil {
+ return nil, err
+ }
+ }
+ opts.DNSSearch = dnsSearches
}
m, err := cmd.Flags().GetString("mac-address")
@@ -85,6 +128,7 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) {
}
opts.StaticMAC = &mac
}
+
inputPorts, err := cmd.Flags().GetStringSlice("publish")
if err != nil {
return nil, err
@@ -95,6 +139,35 @@ func NetFlagsToNetOptions(cmd *cobra.Command) (*entities.NetOptions, error) {
return nil, err
}
}
+
+ ip, err := cmd.Flags().GetString("ip")
+ if err != nil {
+ return nil, err
+ }
+ if ip != "" {
+ staticIP := net.ParseIP(ip)
+ if staticIP == nil {
+ return nil, errors.Errorf("%s is not an ip address", ip)
+ }
+ opts.StaticIP = &staticIP
+ }
+
opts.NoHosts, err = cmd.Flags().GetBool("no-hosts")
+
+ if cmd.Flags().Changed("network") {
+ network, err := cmd.Flags().GetString("network")
+ if err != nil {
+ return nil, err
+ }
+
+ ns, cniNets, err := specgen.ParseNetworkNamespace(network)
+ if err != nil {
+ return nil, err
+ }
+
+ opts.Network = ns
+ opts.CNINetworks = cniNets
+ }
+
return &opts, err
}
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 7550bf784..12fd16551 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -23,49 +23,135 @@ import (
"github.com/pkg/errors"
)
-func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) error {
- var (
- err error
- //namespaces map[string]string
- )
+func getCPULimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxCPU, error) {
+ cpu := &specs.LinuxCPU{}
+ hasLimits := false
- // validate flags as needed
- if err := c.validate(); err != nil {
- return nil
+ if c.CPUShares > 0 {
+ cpu.Shares = &c.CPUShares
+ hasLimits = true
+ }
+ if c.CPUPeriod > 0 {
+ cpu.Period = &c.CPUPeriod
+ hasLimits = true
+ }
+ if c.CPUSetCPUs != "" {
+ cpu.Cpus = c.CPUSetCPUs
+ hasLimits = true
+ }
+ if c.CPUSetMems != "" {
+ cpu.Mems = c.CPUSetMems
+ hasLimits = true
+ }
+ if c.CPUQuota > 0 {
+ cpu.Quota = &c.CPUQuota
+ hasLimits = true
+ }
+ if c.CPURTPeriod > 0 {
+ cpu.RealtimePeriod = &c.CPURTPeriod
+ hasLimits = true
+ }
+ if c.CPURTRuntime > 0 {
+ cpu.RealtimeRuntime = &c.CPURTRuntime
+ hasLimits = true
}
- s.User = c.User
- inputCommand := args[1:]
- if len(c.HealthCmd) > 0 {
- s.HealthConfig, err = makeHealthCheckFromCli(c.HealthCmd, c.HealthInterval, c.HealthRetries, c.HealthTimeout, c.HealthStartPeriod)
+ if !hasLimits {
+ return nil, nil
+ }
+ return cpu, nil
+}
+
+func getIOLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxBlockIO, error) {
+ var err error
+ io := &specs.LinuxBlockIO{}
+ hasLimits := false
+ if b := c.BlkIOWeight; len(b) > 0 {
+ u, err := strconv.ParseUint(b, 10, 16)
if err != nil {
- return err
+ return nil, errors.Wrapf(err, "invalid value for blkio-weight")
}
+ nu := uint16(u)
+ io.Weight = &nu
+ hasLimits = true
}
- s.IDMappings, err = util.ParseIDMapping(ns.UsernsMode(c.UserNS), c.UIDMap, c.GIDMap, c.SubUIDName, c.SubGIDName)
- if err != nil {
- return err
+ if len(c.BlkIOWeightDevice) > 0 {
+ if err := parseWeightDevices(c.BlkIOWeightDevice, s); err != nil {
+ return nil, err
+ }
+ hasLimits = true
}
- if s.ResourceLimits == nil {
- s.ResourceLimits = &specs.LinuxResources{}
+
+ if bps := c.DeviceReadBPs; len(bps) > 0 {
+ if s.ThrottleReadBpsDevice, err = parseThrottleBPSDevices(bps); err != nil {
+ return nil, err
+ }
+ hasLimits = true
+ }
+
+ if bps := c.DeviceWriteBPs; len(bps) > 0 {
+ if s.ThrottleWriteBpsDevice, err = parseThrottleBPSDevices(bps); err != nil {
+ return nil, err
+ }
+ hasLimits = true
+ }
+
+ if iops := c.DeviceReadIOPs; len(iops) > 0 {
+ if s.ThrottleReadIOPSDevice, err = parseThrottleIOPsDevices(iops); err != nil {
+ return nil, err
+ }
+ hasLimits = true
+ }
+
+ if iops := c.DeviceWriteIOPs; len(iops) > 0 {
+ if s.ThrottleWriteIOPSDevice, err = parseThrottleIOPsDevices(iops); err != nil {
+ return nil, err
+ }
+ hasLimits = true
+ }
+
+ if !hasLimits {
+ return nil, nil
+ }
+ return io, nil
+}
+
+func getPidsLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxPids, error) {
+ pids := &specs.LinuxPids{}
+ hasLimits := false
+ if c.PIDsLimit > 0 {
+ pids.Limit = c.PIDsLimit
+ hasLimits = true
+ }
+ if c.CGroups == "disabled" && c.PIDsLimit > 0 {
+ s.ResourceLimits.Pids.Limit = -1
}
- if s.ResourceLimits.Memory == nil {
- s.ResourceLimits.Memory = &specs.LinuxMemory{}
+ if !hasLimits {
+ return nil, nil
}
+ return pids, nil
+}
+
+func getMemoryLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) (*specs.LinuxMemory, error) {
+ var err error
+ memory := &specs.LinuxMemory{}
+ hasLimits := false
if m := c.Memory; len(m) > 0 {
ml, err := units.RAMInBytes(m)
if err != nil {
- return errors.Wrapf(err, "invalid value for memory")
+ return nil, errors.Wrapf(err, "invalid value for memory")
}
- s.ResourceLimits.Memory.Limit = &ml
+ memory.Limit = &ml
+ hasLimits = true
}
if m := c.MemoryReservation; len(m) > 0 {
mr, err := units.RAMInBytes(m)
if err != nil {
- return errors.Wrapf(err, "invalid value for memory")
+ return nil, errors.Wrapf(err, "invalid value for memory")
}
- s.ResourceLimits.Memory.Reservation = &mr
+ memory.Reservation = &mr
+ hasLimits = true
}
if m := c.MemorySwap; len(m) > 0 {
var ms int64
@@ -75,28 +161,58 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
} else {
ms, err = units.RAMInBytes(m)
if err != nil {
- return errors.Wrapf(err, "invalid value for memory")
+ return nil, errors.Wrapf(err, "invalid value for memory")
}
}
- s.ResourceLimits.Memory.Swap = &ms
+ memory.Swap = &ms
+ hasLimits = true
}
if m := c.KernelMemory; len(m) > 0 {
mk, err := units.RAMInBytes(m)
if err != nil {
- return errors.Wrapf(err, "invalid value for kernel-memory")
+ return nil, errors.Wrapf(err, "invalid value for kernel-memory")
}
- s.ResourceLimits.Memory.Kernel = &mk
+ memory.Kernel = &mk
+ hasLimits = true
}
- if s.ResourceLimits.BlockIO == nil {
- s.ResourceLimits.BlockIO = &specs.LinuxBlockIO{}
+ if c.MemorySwappiness >= 0 {
+ swappiness := uint64(c.MemorySwappiness)
+ memory.Swappiness = &swappiness
+ hasLimits = true
}
- if b := c.BlkIOWeight; len(b) > 0 {
- u, err := strconv.ParseUint(b, 10, 16)
+ if c.OOMKillDisable {
+ memory.DisableOOMKiller = &c.OOMKillDisable
+ hasLimits = true
+ }
+ if !hasLimits {
+ return nil, nil
+ }
+ return memory, nil
+}
+
+func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string) error {
+ var (
+ err error
+ //namespaces map[string]string
+ )
+
+ // validate flags as needed
+ if err := c.validate(); err != nil {
+ return nil
+ }
+
+ s.User = c.User
+ inputCommand := args[1:]
+ if len(c.HealthCmd) > 0 {
+ s.HealthConfig, err = makeHealthCheckFromCli(c.HealthCmd, c.HealthInterval, c.HealthRetries, c.HealthTimeout, c.HealthStartPeriod)
if err != nil {
- return errors.Wrapf(err, "invalid value for blkio-weight")
+ return err
}
- nu := uint16(u)
- s.ResourceLimits.BlockIO.Weight = &nu
+ }
+
+ s.IDMappings, err = util.ParseIDMapping(ns.UsernsMode(c.UserNS), c.UIDMap, c.GIDMap, c.SubUIDName, c.SubGIDName)
+ if err != nil {
+ return err
}
s.Terminal = c.TTY
@@ -268,6 +384,8 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
var command []string
+ s.Entrypoint = entrypoint
+
// Build the command
// If we have an entry point, it goes first
if len(entrypoint) > 0 {
@@ -292,9 +410,12 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
}
s.ShmSize = &shmSize
s.HostAdd = c.Net.AddHosts
- s.DNSServer = c.Net.DNSServers
+ s.UseImageResolvConf = c.Net.UseImageResolvConf
+ s.DNSServers = c.Net.DNSServers
s.DNSSearch = c.Net.DNSSearch
- s.DNSOption = c.Net.DNSOptions
+ s.DNSOptions = c.Net.DNSOptions
+ s.StaticIP = c.Net.StaticIP
+ s.StaticMAC = c.Net.StaticMAC
// deferred, must be added on libpod side
//var ImageVolumes map[string]struct{}
@@ -325,12 +446,24 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
if s.ResourceLimits == nil {
s.ResourceLimits = &specs.LinuxResources{}
}
- if s.ResourceLimits.Memory == nil {
- s.ResourceLimits.Memory = &specs.LinuxMemory{}
+ s.ResourceLimits.Memory, err = getMemoryLimits(s, c, args)
+ if err != nil {
+ return err
}
- if c.MemorySwappiness >= 0 {
- swappiness := uint64(c.MemorySwappiness)
- s.ResourceLimits.Memory.Swappiness = &swappiness
+ s.ResourceLimits.BlockIO, err = getIOLimits(s, c, args)
+ if err != nil {
+ return err
+ }
+ s.ResourceLimits.Pids, err = getPidsLimits(s, c, args)
+ if err != nil {
+ return err
+ }
+ s.ResourceLimits.CPU, err = getCPULimits(s, c, args)
+ if err != nil {
+ return err
+ }
+ if s.ResourceLimits.CPU == nil && s.ResourceLimits.Pids == nil && s.ResourceLimits.BlockIO == nil && s.ResourceLimits.Memory == nil {
+ s.ResourceLimits = nil
}
if s.LogConfiguration == nil {
@@ -340,15 +473,6 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
if ld := c.LogDriver; len(ld) > 0 {
s.LogConfiguration.Driver = ld
}
- if s.ResourceLimits.Pids == nil {
- s.ResourceLimits.Pids = &specs.LinuxPids{}
- }
- if c.PIDsLimit > 0 {
- s.ResourceLimits.Pids.Limit = c.PIDsLimit
- }
- if c.CGroups == "disabled" && c.PIDsLimit > 0 {
- s.ResourceLimits.Pids.Limit = -1
- }
// TODO WTF
//cgroup := &cc.CgroupConfig{
// Cgroups: c.String("cgroups"),
@@ -454,32 +578,6 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
// quiet
//DeviceCgroupRules: c.StringSlice("device-cgroup-rule"),
- if bps := c.DeviceReadBPs; len(bps) > 0 {
- if s.ThrottleReadBpsDevice, err = parseThrottleBPSDevices(bps); err != nil {
- return err
- }
- }
-
- if bps := c.DeviceWriteBPs; len(bps) > 0 {
- if s.ThrottleWriteBpsDevice, err = parseThrottleBPSDevices(bps); err != nil {
- return err
- }
- }
-
- if iops := c.DeviceReadIOPs; len(iops) > 0 {
- if s.ThrottleReadIOPSDevice, err = parseThrottleIOPsDevices(iops); err != nil {
- return err
- }
- }
-
- if iops := c.DeviceWriteIOPs; len(iops) > 0 {
- if s.ThrottleWriteIOPSDevice, err = parseThrottleIOPsDevices(iops); err != nil {
- return err
- }
- }
-
- s.ResourceLimits.Memory.DisableOOMKiller = &c.OOMKillDisable
-
// Rlimits/Ulimits
for _, u := range c.Ulimit {
if u == "host" {
@@ -514,35 +612,6 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
s.LogConfiguration.Options = logOpts
s.Name = c.Name
- if err := parseWeightDevices(c.BlkIOWeightDevice, s); err != nil {
- return err
- }
-
- if s.ResourceLimits.CPU == nil {
- s.ResourceLimits.CPU = &specs.LinuxCPU{}
- }
- if c.CPUShares > 0 {
- s.ResourceLimits.CPU.Shares = &c.CPUShares
- }
- if c.CPUPeriod > 0 {
- s.ResourceLimits.CPU.Period = &c.CPUPeriod
- }
-
- if c.CPUSetCPUs != "" {
- s.ResourceLimits.CPU.Cpus = c.CPUSetCPUs
- }
- if c.CPUSetMems != "" {
- s.ResourceLimits.CPU.Mems = c.CPUSetMems
- }
- if c.CPUQuota > 0 {
- s.ResourceLimits.CPU.Quota = &c.CPUQuota
- }
- if c.CPURTPeriod > 0 {
- s.ResourceLimits.CPU.RealtimePeriod = &c.CPURTPeriod
- }
- if c.CPURTRuntime > 0 {
- s.ResourceLimits.CPU.RealtimeRuntime = &c.CPURTRuntime
- }
s.OOMScoreAdj = &c.OOMScoreAdj
s.RestartPolicy = c.Restart
s.Remove = c.Rm
diff --git a/cmd/podman/containers/attach.go b/cmd/podman/containers/attach.go
index 700be1f84..78b52ad1b 100644
--- a/cmd/podman/containers/attach.go
+++ b/cmd/podman/containers/attach.go
@@ -3,11 +3,11 @@ package containers
import (
"os"
- "github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -27,19 +27,24 @@ var (
podman attach 1234
podman attach --no-stdin foobar`,
}
+
+ containerAttachCommand = &cobra.Command{
+ Use: attachCommand.Use,
+ Short: attachCommand.Short,
+ Long: attachCommand.Long,
+ RunE: attachCommand.RunE,
+ Example: `podman container attach ctrID
+ podman container attach 1234
+ podman container attach --no-stdin foobar`,
+ }
)
var (
attachOpts entities.AttachOptions
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode},
- Command: attachCommand,
- })
- flags := attachCommand.Flags()
- flags.StringVar(&attachOpts.DetachKeys, "detach-keys", common.GetDefaultDetachKeys(), "Select the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
+func attachFlags(flags *pflag.FlagSet) {
+ flags.StringVar(&attachOpts.DetachKeys, "detach-keys", containerConfig.DetachKeys(), "Select the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
flags.BoolVar(&attachOpts.NoStdin, "no-stdin", false, "Do not attach STDIN. The default is false")
flags.BoolVar(&attachOpts.SigProxy, "sig-proxy", true, "Proxy received signals to the process")
flags.BoolVarP(&attachOpts.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
@@ -48,6 +53,23 @@ func init() {
}
}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: attachCommand,
+ })
+ flags := attachCommand.Flags()
+ attachFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: containerAttachCommand,
+ Parent: containerCmd,
+ })
+ containerAttachFlags := containerAttachCommand.Flags()
+ attachFlags(containerAttachFlags)
+}
+
func attach(cmd *cobra.Command, args []string) error {
attachOpts.Stdin = os.Stdin
if attachOpts.NoStdin {
diff --git a/cmd/podman/containers/commit.go b/cmd/podman/containers/commit.go
index eaba07981..137e486eb 100644
--- a/cmd/podman/containers/commit.go
+++ b/cmd/podman/containers/commit.go
@@ -11,6 +11,7 @@ import (
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -28,6 +29,17 @@ var (
podman commit containerID`,
}
+ containerCommitCommand = &cobra.Command{
+ Use: commitCommand.Use,
+ Short: commitCommand.Short,
+ Long: commitCommand.Long,
+ RunE: commitCommand.RunE,
+ Example: `podman container commit -q --message "committing container to image" reverent_golick image-committed
+ podman container commit -q --author "firstName lastName" reverent_golick image-committed
+ podman container commit -q --pause=false containerID image-committed
+ podman container commit containerID`,
+ }
+
// ChangeCmds is the list of valid Changes commands to passed to the Commit call
ChangeCmds = []string{"CMD", "ENTRYPOINT", "ENV", "EXPOSE", "LABEL", "ONBUILD", "STOPSIGNAL", "USER", "VOLUME", "WORKDIR"}
)
@@ -39,12 +51,7 @@ var (
iidFile string
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: commitCommand,
- })
- flags := commitCommand.Flags()
+func commitFlags(flags *pflag.FlagSet) {
flags.StringArrayVarP(&commitOptions.Changes, "change", "c", []string{}, "Apply the following possible instructions to the created image (default []): "+strings.Join(ChangeCmds, " | "))
flags.StringVarP(&commitOptions.Format, "format", "f", "oci", "`Format` of the image manifest and metadata")
flags.StringVarP(&iidFile, "iidfile", "", "", "`file` to write the image ID to")
@@ -53,8 +60,25 @@ func init() {
flags.BoolVarP(&commitOptions.Pause, "pause", "p", false, "Pause container during commit")
flags.BoolVarP(&commitOptions.Quiet, "quiet", "q", false, "Suppress output")
flags.BoolVar(&commitOptions.IncludeVolumes, "include-volumes", false, "Include container volumes as image volumes")
+}
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: commitCommand,
+ })
+ flags := commitCommand.Flags()
+ commitFlags(flags)
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerCommitCommand,
+ Parent: containerCmd,
+ })
+ containerCommitFlags := containerCommitCommand.Flags()
+ commitFlags(containerCommitFlags)
}
+
func commit(cmd *cobra.Command, args []string) error {
container := args[0]
if len(args) > 1 {
diff --git a/cmd/podman/containers/container.go b/cmd/podman/containers/container.go
index 8564b23f4..4b1733eb0 100644
--- a/cmd/podman/containers/container.go
+++ b/cmd/podman/containers/container.go
@@ -1,12 +1,9 @@
package containers
import (
- "os"
-
- "github.com/containers/common/pkg/config"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/pkg/domain/entities"
- "github.com/sirupsen/logrus"
+ "github.com/containers/libpod/pkg/util"
"github.com/spf13/cobra"
)
@@ -20,7 +17,7 @@ var (
RunE: registry.SubCommandExists,
}
- defaultContainerConfig = getDefaultContainerConfig()
+ containerConfig = util.DefaultContainerConfig()
)
func init() {
@@ -29,12 +26,3 @@ func init() {
Command: containerCmd,
})
}
-
-func getDefaultContainerConfig() *config.Config {
- defaultContainerConfig, err := config.Default()
- if err != nil {
- logrus.Error(err)
- os.Exit(1)
- }
- return defaultContainerConfig
-}
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
new file mode 100644
index 000000000..f0f9a158d
--- /dev/null
+++ b/cmd/podman/containers/cp.go
@@ -0,0 +1,55 @@
+package containers
+
+import (
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/cgroups"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/rootless"
+ "github.com/sirupsen/logrus"
+ "github.com/spf13/cobra"
+)
+
+var (
+ cpDescription = `Command copies the contents of SRC_PATH to the DEST_PATH.
+
+ You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container. If "-" is specified for either the SRC_PATH or DEST_PATH, you can also stream a tar archive from STDIN or to STDOUT. The CONTAINER can be a running or stopped container. The SRC_PATH or DEST_PATH can be a file or directory.
+`
+ cpCommand = &cobra.Command{
+ Use: "cp [flags] SRC_PATH DEST_PATH",
+ Short: "Copy files/folders between a container and the local filesystem",
+ Long: cpDescription,
+ Args: cobra.ExactArgs(2),
+ RunE: cp,
+ Example: "podman cp [CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH",
+ }
+)
+
+var (
+ cpOpts entities.ContainerCpOptions
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: cpCommand,
+ })
+ flags := cpCommand.Flags()
+ flags.BoolVar(&cpOpts.Extract, "extract", false, "Extract the tar file into the destination directory.")
+ flags.BoolVar(&cpOpts.Pause, "pause", copyPause(), "Pause the container while copying")
+}
+
+func cp(cmd *cobra.Command, args []string) error {
+ _, err := registry.ContainerEngine().ContainerCp(registry.GetContext(), args[0], args[1], cpOpts)
+ return err
+}
+
+func copyPause() bool {
+ if rootless.IsRootless() {
+ cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
+ if !cgroupv2 {
+ logrus.Debugf("defaulting to pause==false on rootless cp in cgroupv1 systems")
+ return false
+ }
+ }
+ return true
+}
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index 0843789eb..0c96f1a5c 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -27,12 +28,29 @@ var (
podman create --annotation HELLO=WORLD alpine ls
podman create -t -i --name myctr alpine ls`,
}
+
+ containerCreateCommand = &cobra.Command{
+ Use: createCommand.Use,
+ Short: createCommand.Short,
+ Long: createCommand.Long,
+ RunE: createCommand.RunE,
+ Example: `podman container create alpine ls
+ podman container create --annotation HELLO=WORLD alpine ls
+ podman container create -t -i --name myctr alpine ls`,
+ }
)
var (
cliVals common.ContainerCLIOpts
)
+func createFlags(flags *pflag.FlagSet) {
+ flags.SetInterspersed(false)
+ flags.AddFlagSet(common.GetCreateFlags(&cliVals))
+ flags.AddFlagSet(common.GetNetFlags())
+ flags.SetNormalizeFunc(common.AliasFlags)
+}
+
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
@@ -40,10 +58,16 @@ func init() {
})
//common.GetCreateFlags(createCommand)
flags := createCommand.Flags()
- flags.SetInterspersed(false)
- flags.AddFlagSet(common.GetCreateFlags(&cliVals))
- flags.AddFlagSet(common.GetNetFlags())
- flags.SetNormalizeFunc(common.AliasFlags)
+ createFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerCreateCommand,
+ Parent: containerCmd,
+ })
+
+ containerCreateFlags := containerCreateCommand.Flags()
+ createFlags(containerCreateFlags)
}
func create(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/exec.go b/cmd/podman/containers/exec.go
index 68ecb2196..3749c934a 100644
--- a/cmd/podman/containers/exec.go
+++ b/cmd/podman/containers/exec.go
@@ -4,12 +4,12 @@ import (
"bufio"
"os"
- "github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/pkg/domain/entities"
envLib "github.com/containers/libpod/pkg/env"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -24,6 +24,16 @@ var (
podman exec -it -w /tmp myCtr pwd
podman exec --user root ctrID ls`,
}
+
+ containerExecCommand = &cobra.Command{
+ Use: execCommand.Use,
+ Short: execCommand.Short,
+ Long: execCommand.Long,
+ RunE: execCommand.RunE,
+ Example: `podman container exec -it ctrID ls
+ podman container exec -it -w /tmp myCtr pwd
+ podman container exec --user root ctrID ls`,
+ }
)
var (
@@ -31,14 +41,9 @@ var (
execOpts entities.ExecOptions
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode},
- Command: execCommand,
- })
- flags := execCommand.Flags()
+func execFlags(flags *pflag.FlagSet) {
flags.SetInterspersed(false)
- flags.StringVar(&execOpts.DetachKeys, "detach-keys", common.GetDefaultDetachKeys(), "Select the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
+ flags.StringVar(&execOpts.DetachKeys, "detach-keys", containerConfig.DetachKeys(), "Select the key sequence for detaching a container. Format is a single character [a-Z] or ctrl-<value> where <value> is one of: a-z, @, ^, [, , or _")
flags.StringArrayVarP(&envInput, "env", "e", []string{}, "Set environment variables")
flags.StringSliceVar(&envFile, "env-file", []string{}, "Read in a file of environment variables")
flags.BoolVarP(&execOpts.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
@@ -52,8 +57,26 @@ func init() {
_ = flags.MarkHidden("latest")
_ = flags.MarkHidden("preserve-fds")
}
+}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: execCommand,
+ })
+ flags := execCommand.Flags()
+ execFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: containerExecCommand,
+ Parent: containerCommitCommand,
+ })
+
+ containerExecFlags := containerExecCommand.Flags()
+ execFlags(containerExecFlags)
}
+
func exec(cmd *cobra.Command, args []string) error {
var nameOrId string
execOpts.Cmd = args
diff --git a/cmd/podman/containers/export.go b/cmd/podman/containers/export.go
index 5110812d1..fb5bd468f 100644
--- a/cmd/podman/containers/export.go
+++ b/cmd/podman/containers/export.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
"golang.org/x/crypto/ssh/terminal"
)
@@ -25,19 +26,41 @@ var (
Example: `podman export ctrID > myCtr.tar
podman export --output="myCtr.tar" ctrID`,
}
+
+ containerExportCommand = &cobra.Command{
+ Use: exportCommand.Use,
+ Short: exportCommand.Short,
+ Long: exportCommand.Long,
+ RunE: exportCommand.RunE,
+ Example: `podman container export ctrID > myCtr.tar
+ podman container export --output="myCtr.tar" ctrID`,
+ }
)
var (
exportOpts entities.ContainerExportOptions
)
+func exportFlags(flags *pflag.FlagSet) {
+ flags.StringVarP(&exportOpts.Output, "output", "o", "", "Write to a specified file (default: stdout, which must be redirected)")
+}
+
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: exportCommand,
})
flags := exportCommand.Flags()
- flags.StringVarP(&exportOpts.Output, "output", "o", "", "Write to a specified file (default: stdout, which must be redirected)")
+ exportFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerExportCommand,
+ Parent: containerCmd,
+ })
+
+ containerExportFlags := containerExportCommand.Flags()
+ exportFlags(containerExportFlags)
}
func export(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/kill.go b/cmd/podman/containers/kill.go
index 5341457fb..8b4a384fe 100644
--- a/cmd/podman/containers/kill.go
+++ b/cmd/podman/containers/kill.go
@@ -11,6 +11,7 @@ import (
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/signal"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -27,18 +28,23 @@ var (
podman kill 860a4b23
podman kill --signal TERM ctrID`,
}
+
+ containerKillCommand = &cobra.Command{
+ Use: killCommand.Use,
+ Short: killCommand.Short,
+ Long: killCommand.Long,
+ RunE: killCommand.RunE,
+ Example: `podman container kill mywebserver
+ podman container kill 860a4b23
+ podman container kill --signal TERM ctrID`,
+ }
)
var (
killOptions = entities.KillOptions{}
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: killCommand,
- })
- flags := killCommand.Flags()
+func killFlags(flags *pflag.FlagSet) {
flags.BoolVarP(&killOptions.All, "all", "a", false, "Signal all running containers")
flags.StringVarP(&killOptions.Signal, "signal", "s", "KILL", "Signal to send to the container")
flags.BoolVarP(&killOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
@@ -47,6 +53,24 @@ func init() {
}
}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: killCommand,
+ })
+ flags := killCommand.Flags()
+ killFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerKillCommand,
+ Parent: containerCmd,
+ })
+
+ containerKillFlags := containerKillCommand.Flags()
+ killFlags(containerKillFlags)
+}
+
func kill(cmd *cobra.Command, args []string) error {
var (
err error
diff --git a/cmd/podman/containers/mount.go b/cmd/podman/containers/mount.go
index 25eec46ca..d0d132546 100644
--- a/cmd/podman/containers/mount.go
+++ b/cmd/podman/containers/mount.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/libpod/cmd/podman/utils"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -34,22 +35,41 @@ var (
registry.ParentNSRequired: "",
},
}
+
+ containerMountCommmand = &cobra.Command{
+ Use: mountCommand.Use,
+ Short: mountCommand.Short,
+ Long: mountCommand.Long,
+ RunE: mountCommand.RunE,
+ }
)
var (
mountOpts entities.ContainerMountOptions
)
+func mountFlags(flags *pflag.FlagSet) {
+ flags.BoolVarP(&mountOpts.All, "all", "a", false, "Mount all containers")
+ flags.StringVar(&mountOpts.Format, "format", "", "Change the output format to Go template")
+ flags.BoolVarP(&mountOpts.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
+ flags.BoolVar(&mountOpts.NoTruncate, "notruncate", false, "Do not truncate output")
+}
+
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: mountCommand,
})
flags := mountCommand.Flags()
- flags.BoolVarP(&mountOpts.All, "all", "a", false, "Mount all containers")
- flags.StringVar(&mountOpts.Format, "format", "", "Change the output format to Go template")
- flags.BoolVarP(&mountOpts.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
- flags.BoolVar(&mountOpts.NoTruncate, "notruncate", false, "Do not truncate output")
+ mountFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: containerMountCommmand,
+ Parent: containerCmd,
+ })
+ containerMountFlags := containerMountCommmand.Flags()
+ mountFlags(containerMountFlags)
}
func mount(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/pause.go b/cmd/podman/containers/pause.go
index f3654b5c1..b932c4539 100644
--- a/cmd/podman/containers/pause.go
+++ b/cmd/podman/containers/pause.go
@@ -10,6 +10,7 @@ import (
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -24,16 +25,38 @@ var (
podman pause -a`,
}
+ containerPauseCommand = &cobra.Command{
+ Use: pauseCommand.Use,
+ Short: pauseCommand.Short,
+ Long: pauseCommand.Long,
+ RunE: pauseCommand.RunE,
+ Example: `podman container pause mywebserver
+ podman container pause 860a4b23
+ podman container pause -a`,
+ }
+
pauseOpts = entities.PauseUnPauseOptions{}
)
+func pauseFlags(flags *pflag.FlagSet) {
+ flags.BoolVarP(&pauseOpts.All, "all", "a", false, "Pause all running containers")
+}
+
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: pauseCommand,
})
flags := pauseCommand.Flags()
- flags.BoolVarP(&pauseOpts.All, "all", "a", false, "Pause all running containers")
+ pauseFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerPauseCommand,
+ Parent: containerCmd,
+ })
+ containerPauseFlags := containerPauseCommand.Flags()
+ pauseFlags(containerPauseFlags)
}
func pause(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/port.go b/cmd/podman/containers/port.go
new file mode 100644
index 000000000..0e50140ca
--- /dev/null
+++ b/cmd/podman/containers/port.go
@@ -0,0 +1,123 @@
+package containers
+
+import (
+ "fmt"
+ "strconv"
+ "strings"
+
+ "github.com/containers/libpod/cmd/podman/parse"
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/cri-o/ocicni/pkg/ocicni"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ portDescription = `List port mappings for the CONTAINER, or lookup the public-facing port that is NAT-ed to the PRIVATE_PORT
+`
+ portCommand = &cobra.Command{
+ Use: "port [flags] CONTAINER [PORT]",
+ Short: "List port mappings or a specific mapping for the container",
+ Long: portDescription,
+ RunE: port,
+ Args: func(cmd *cobra.Command, args []string) error {
+ return parse.CheckAllLatestAndCIDFile(cmd, args, true, false)
+ },
+ Example: `podman port --all
+ podman port ctrID 80/tcp
+ podman port --latest 80`,
+ }
+)
+
+var (
+ portOpts entities.ContainerPortOptions
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: portCommand,
+ })
+ flags := portCommand.Flags()
+ flags.BoolVarP(&portOpts.All, "all", "a", false, "Display port information for all containers")
+ flags.BoolVarP(&portOpts.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
+ if registry.IsRemote() {
+ _ = flags.MarkHidden("latest")
+ }
+}
+
+func port(cmd *cobra.Command, args []string) error {
+ var (
+ container string
+ err error
+ userPort ocicni.PortMapping
+ )
+
+ if len(args) == 0 && !portOpts.Latest && !portOpts.All {
+ return errors.Errorf("you must supply a running container name or id")
+ }
+ if !portOpts.Latest && len(args) >= 1 {
+ container = args[0]
+ }
+ port := ""
+ if len(args) > 1 && !portOpts.Latest {
+ port = args[1]
+ }
+ if len(args) == 1 && portOpts.Latest {
+ port = args[0]
+ }
+ if len(port) > 0 {
+ fields := strings.Split(port, "/")
+ if len(fields) > 2 || len(fields) < 1 {
+ return errors.Errorf("port formats are port/protocol. '%s' is invalid", port)
+ }
+ if len(fields) == 1 {
+ fields = append(fields, "tcp")
+ }
+
+ portNum, err := strconv.Atoi(fields[0])
+ if err != nil {
+ return err
+ }
+ userPort = ocicni.PortMapping{
+ HostPort: 0,
+ ContainerPort: int32(portNum),
+ Protocol: fields[1],
+ HostIP: "",
+ }
+ }
+
+ reports, err := registry.ContainerEngine().ContainerPort(registry.GetContext(), container, portOpts)
+ if err != nil {
+ return err
+ }
+ var found bool
+ // Iterate mappings
+ for _, report := range reports {
+ for _, v := range report.Ports {
+ hostIP := v.HostIP
+ // Set host IP to 0.0.0.0 if blank
+ if hostIP == "" {
+ hostIP = "0.0.0.0"
+ }
+ if portOpts.All {
+ fmt.Printf("%s\t", report.Id[:12])
+ }
+ // If not searching by port or port/proto, then dump what we see
+ if port == "" {
+ fmt.Printf("%d/%s -> %s:%d\n", v.ContainerPort, v.Protocol, hostIP, v.HostPort)
+ continue
+ }
+ if v == userPort {
+ fmt.Printf("%s:%d\n", hostIP, v.HostPort)
+ found = true
+ break
+ }
+ }
+ if !found && port != "" {
+ return errors.Errorf("failed to find published port %q", port)
+ }
+ }
+ return nil
+}
diff --git a/cmd/podman/containers/restart.go b/cmd/podman/containers/restart.go
index 68b6de4ca..1a9d7f6c7 100644
--- a/cmd/podman/containers/restart.go
+++ b/cmd/podman/containers/restart.go
@@ -11,12 +11,13 @@ import (
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
restartDescription = fmt.Sprintf(`Restarts one or more running containers. The container ID or name can be used.
- A timeout before forcibly stopping can be set, but defaults to %d seconds.`, defaultContainerConfig.Engine.StopTimeout)
+ A timeout before forcibly stopping can be set, but defaults to %d seconds.`, containerConfig.Engine.StopTimeout)
restartCommand = &cobra.Command{
Use: "restart [flags] CONTAINER [CONTAINER...]",
@@ -30,6 +31,16 @@ var (
podman restart --latest
podman restart ctrID1 ctrID2`,
}
+
+ containerRestartCommand = &cobra.Command{
+ Use: restartCommand.Use,
+ Short: restartCommand.Short,
+ Long: restartCommand.Long,
+ RunE: restartCommand.RunE,
+ Example: `podman container restart ctrID
+ podman container restart --latest
+ podman container restart ctrID1 ctrID2`,
+ }
)
var (
@@ -37,22 +48,35 @@ var (
restartTimeout uint
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: restartCommand,
- })
- flags := restartCommand.Flags()
+func restartFlags(flags *pflag.FlagSet) {
flags.BoolVarP(&restartOptions.All, "all", "a", false, "Restart all non-running containers")
flags.BoolVarP(&restartOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&restartOptions.Running, "running", false, "Restart only running containers when --all is used")
- flags.UintVarP(&restartTimeout, "time", "t", defaultContainerConfig.Engine.StopTimeout, "Seconds to wait for stop before killing the container")
+ flags.UintVarP(&restartTimeout, "time", "t", containerConfig.Engine.StopTimeout, "Seconds to wait for stop before killing the container")
if registry.IsRemote() {
_ = flags.MarkHidden("latest")
}
flags.SetNormalizeFunc(utils.AliasFlags)
}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: restartCommand,
+ })
+ flags := restartCommand.Flags()
+ restartFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerRestartCommand,
+ Parent: containerCmd,
+ })
+
+ containerRestartFlags := containerRestartCommand.Flags()
+ restartFlags(containerRestartFlags)
+}
+
func restart(cmd *cobra.Command, args []string) error {
var (
errs utils.OutputErrors
diff --git a/cmd/podman/containers/rm.go b/cmd/podman/containers/rm.go
index a22880d93..12a7a3d89 100644
--- a/cmd/podman/containers/rm.go
+++ b/cmd/podman/containers/rm.go
@@ -12,6 +12,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -31,18 +32,24 @@ var (
podman rm --force --all
podman rm -f c684f0d469f2`,
}
+
+ containerRmCommand = &cobra.Command{
+ Use: rmCommand.Use,
+ Short: rmCommand.Use,
+ Long: rmCommand.Long,
+ RunE: rmCommand.RunE,
+ Example: `podman container rm imageID
+ podman container rm mywebserver myflaskserver 860a4b23
+ podman container rm --force --all
+ podman container rm -f c684f0d469f2`,
+ }
)
var (
rmOptions = entities.RmOptions{}
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: rmCommand,
- })
- flags := rmCommand.Flags()
+func rmFlags(flags *pflag.FlagSet) {
flags.BoolVarP(&rmOptions.All, "all", "a", false, "Remove all containers")
flags.BoolVarP(&rmOptions.Ignore, "ignore", "i", false, "Ignore errors when a specified container is missing")
flags.BoolVarP(&rmOptions.Force, "force", "f", false, "Force removal of a running or unusable container. The default is false")
@@ -56,7 +63,24 @@ func init() {
_ = flags.MarkHidden("cidfile")
_ = flags.MarkHidden("storage")
}
+}
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: rmCommand,
+ })
+ flags := rmCommand.Flags()
+ rmFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerRmCommand,
+ Parent: containerCmd,
+ })
+ containerRmFlags := containerRmCommand.Flags()
+ rmFlags(containerRmFlags)
}
func rm(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go
index 9d222e44d..06b89b0fc 100644
--- a/cmd/podman/containers/run.go
+++ b/cmd/podman/containers/run.go
@@ -13,6 +13,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -26,6 +27,16 @@ var (
podman run --network=host imageID dnf -y install java
podman run --volume /var/hostdir:/var/ctrdir -i -t fedora /bin/bash`,
}
+
+ containerRunCommand = &cobra.Command{
+ Use: runCommand.Use,
+ Short: runCommand.Short,
+ Long: runCommand.Long,
+ RunE: runCommand.RunE,
+ Example: `podman container run imageID ls -alF /etc
+ podman container run --network=host imageID dnf -y install java
+ podman container run --volume /var/hostdir:/var/ctrdir -i -t fedora /bin/bash`,
+ }
)
var (
@@ -37,12 +48,7 @@ var (
runRmi bool
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode},
- Command: runCommand,
- })
- flags := runCommand.Flags()
+func runFlags(flags *pflag.FlagSet) {
flags.SetInterspersed(false)
flags.AddFlagSet(common.GetCreateFlags(&cliVals))
flags.AddFlagSet(common.GetNetFlags())
@@ -53,6 +59,23 @@ func init() {
_ = flags.MarkHidden("authfile")
}
}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: runCommand,
+ })
+ flags := runCommand.Flags()
+ runFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: containerRunCommand,
+ Parent: containerCmd,
+ })
+
+ containerRunFlags := containerRunCommand.Flags()
+ runFlags(containerRunFlags)
+}
func run(cmd *cobra.Command, args []string) error {
var err error
@@ -122,7 +145,7 @@ func run(cmd *cobra.Command, args []string) error {
return nil
}
if runRmi {
- _, err := registry.ImageEngine().Delete(registry.GetContext(), []string{args[0]}, entities.ImageDeleteOptions{})
+ _, err := registry.ImageEngine().Remove(registry.GetContext(), []string{args[0]}, entities.ImageRemoveOptions{})
if err != nil {
logrus.Errorf("%s", errors.Wrapf(err, "failed removing image"))
}
diff --git a/cmd/podman/containers/start.go b/cmd/podman/containers/start.go
index 33e5a3094..73f37e51f 100644
--- a/cmd/podman/containers/start.go
+++ b/cmd/podman/containers/start.go
@@ -4,13 +4,13 @@ import (
"fmt"
"os"
- "github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/utils"
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -25,20 +25,25 @@ var (
podman start 860a4b231279 5421ab43b45
podman start --interactive --attach imageID`,
}
+
+ containerStartCommand = &cobra.Command{
+ Use: startCommand.Use,
+ Short: startCommand.Short,
+ Long: startCommand.Long,
+ RunE: startCommand.RunE,
+ Example: `podman container start --latest
+ podman container start 860a4b231279 5421ab43b45
+ podman container start --interactive --attach imageID`,
+ }
)
var (
startOptions entities.ContainerStartOptions
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode},
- Command: startCommand,
- })
- flags := startCommand.Flags()
+func startFlags(flags *pflag.FlagSet) {
flags.BoolVarP(&startOptions.Attach, "attach", "a", false, "Attach container's STDOUT and STDERR")
- flags.StringVar(&startOptions.DetachKeys, "detach-keys", common.GetDefaultDetachKeys(), "Select the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
+ flags.StringVar(&startOptions.DetachKeys, "detach-keys", containerConfig.DetachKeys(), "Select the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-<value>`, where `<value>` is one of: `a-z`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`")
flags.BoolVarP(&startOptions.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.BoolVarP(&startOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&startOptions.SigProxy, "sig-proxy", false, "Proxy received signals to the process (default true if attaching, false otherwise)")
@@ -46,7 +51,23 @@ func init() {
_ = flags.MarkHidden("latest")
_ = flags.MarkHidden("sig-proxy")
}
+}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: startCommand,
+ })
+ flags := startCommand.Flags()
+ startFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: containerStartCommand,
+ Parent: containerCmd,
+ })
+ containerStartFlags := containerStartCommand.Flags()
+ startFlags(containerStartFlags)
}
func start(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/stop.go b/cmd/podman/containers/stop.go
index c1560be08..4a451134a 100644
--- a/cmd/podman/containers/stop.go
+++ b/cmd/podman/containers/stop.go
@@ -9,12 +9,13 @@ import (
"github.com/containers/libpod/cmd/podman/utils"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
stopDescription = fmt.Sprintf(`Stops one or more running containers. The container name or ID can be used.
- A timeout to forcibly stop the container can also be set but defaults to %d seconds otherwise.`, defaultContainerConfig.Engine.StopTimeout)
+ A timeout to forcibly stop the container can also be set but defaults to %d seconds otherwise.`, containerConfig.Engine.StopTimeout)
stopCommand = &cobra.Command{
Use: "stop [flags] CONTAINER [CONTAINER...]",
Short: "Stop one or more containers",
@@ -27,6 +28,16 @@ var (
podman stop --latest
podman stop --time 2 mywebserver 6e534f14da9d`,
}
+
+ containerStopCommand = &cobra.Command{
+ Use: stopCommand.Use,
+ Short: stopCommand.Short,
+ Long: stopCommand.Long,
+ RunE: stopCommand.RunE,
+ Example: `podman container stop ctrID
+ podman container stop --latest
+ podman container stop --time 2 mywebserver 6e534f14da9d`,
+ }
)
var (
@@ -34,17 +45,12 @@ var (
stopTimeout uint
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: stopCommand,
- })
- flags := stopCommand.Flags()
+func stopFlags(flags *pflag.FlagSet) {
flags.BoolVarP(&stopOptions.All, "all", "a", false, "Stop all running containers")
flags.BoolVarP(&stopOptions.Ignore, "ignore", "i", false, "Ignore errors when a specified container is missing")
flags.StringArrayVarP(&stopOptions.CIDFiles, "cidfile", "", nil, "Read the container ID from the file")
flags.BoolVarP(&stopOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
- flags.UintVarP(&stopTimeout, "time", "t", defaultContainerConfig.Engine.StopTimeout, "Seconds to wait for stop before killing the container")
+ flags.UintVarP(&stopTimeout, "time", "t", containerConfig.Engine.StopTimeout, "Seconds to wait for stop before killing the container")
if registry.IsRemote() {
_ = flags.MarkHidden("latest")
@@ -54,11 +60,29 @@ func init() {
flags.SetNormalizeFunc(utils.AliasFlags)
}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: stopCommand,
+ })
+ flags := stopCommand.Flags()
+ stopFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerStopCommand,
+ Parent: containerCmd,
+ })
+
+ containerStopFlags := containerStopCommand.Flags()
+ stopFlags(containerStopFlags)
+}
+
func stop(cmd *cobra.Command, args []string) error {
var (
errs utils.OutputErrors
)
- stopOptions.Timeout = defaultContainerConfig.Engine.StopTimeout
+ stopOptions.Timeout = containerConfig.Engine.StopTimeout
if cmd.Flag("time").Changed {
stopOptions.Timeout = stopTimeout
}
diff --git a/cmd/podman/containers/top.go b/cmd/podman/containers/top.go
index db5213863..732a08623 100644
--- a/cmd/podman/containers/top.go
+++ b/cmd/podman/containers/top.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/psgo"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -36,25 +37,46 @@ podman top --latest
podman top ctrID pid seccomp args %C
podman top ctrID -eo user,pid,comm`,
}
-)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: topCommand,
- })
+ containerTopCommand = &cobra.Command{
+ Use: topCommand.Use,
+ Short: topCommand.Short,
+ Long: topCommand.Long,
+ RunE: topCommand.RunE,
+ Example: `podman container top ctrID
+podman container top --latest
+podman container top ctrID pid seccomp args %C
+podman container top ctrID -eo user,pid,comm`,
+ }
+)
- flags := topCommand.Flags()
+func topFlags(flags *pflag.FlagSet) {
flags.SetInterspersed(false)
flags.BoolVar(&topOptions.ListDescriptors, "list-descriptors", false, "")
flags.BoolVarP(&topOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
-
_ = flags.MarkHidden("list-descriptors") // meant only for bash completion
if registry.IsRemote() {
_ = flags.MarkHidden("latest")
}
}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: topCommand,
+ })
+ flags := topCommand.Flags()
+ topFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerTopCommand,
+ Parent: containerCmd,
+ })
+ containerTopFlags := containerTopCommand.Flags()
+ topFlags(containerTopFlags)
+}
+
func top(cmd *cobra.Command, args []string) error {
if topOptions.ListDescriptors {
fmt.Println(strings.Join(psgo.ListDescriptors(), "\n"))
diff --git a/cmd/podman/containers/unmount.go b/cmd/podman/containers/unmount.go
index 3dbfc1eae..a4550abbd 100644
--- a/cmd/podman/containers/unmount.go
+++ b/cmd/podman/containers/unmount.go
@@ -8,6 +8,7 @@ import (
"github.com/containers/libpod/cmd/podman/utils"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -30,21 +31,44 @@ var (
podman umount ctrID1 ctrID2 ctrID3
podman umount --all`,
}
+
+ containerUnmountCommand = &cobra.Command{
+ Use: umountCommand.Use,
+ Short: umountCommand.Short,
+ Long: umountCommand.Long,
+ RunE: umountCommand.RunE,
+ Example: `podman container umount ctrID
+ podman container umount ctrID1 ctrID2 ctrID3
+ podman container umount --all`,
+ }
)
var (
unmountOpts entities.ContainerUnmountOptions
)
+func umountFlags(flags *pflag.FlagSet) {
+ flags.BoolVarP(&unmountOpts.All, "all", "a", false, "Umount all of the currently mounted containers")
+ flags.BoolVarP(&unmountOpts.Force, "force", "f", false, "Force the complete umount all of the currently mounted containers")
+ flags.BoolVarP(&unmountOpts.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
+}
+
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode},
Command: umountCommand,
})
flags := umountCommand.Flags()
- flags.BoolVarP(&unmountOpts.All, "all", "a", false, "Umount all of the currently mounted containers")
- flags.BoolVarP(&unmountOpts.Force, "force", "f", false, "Force the complete umount all of the currently mounted containers")
- flags.BoolVarP(&unmountOpts.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
+ umountFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: containerUnmountCommand,
+ Parent: containerCmd,
+ })
+
+ containerUmountFlags := containerUnmountCommand.Flags()
+ umountFlags(containerUmountFlags)
}
func unmount(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/unpause.go b/cmd/podman/containers/unpause.go
index ef874b042..adf8d12ee 100644
--- a/cmd/podman/containers/unpause.go
+++ b/cmd/podman/containers/unpause.go
@@ -10,6 +10,7 @@ import (
"github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -23,16 +24,37 @@ var (
podman unpause --all`,
}
unPauseOptions = entities.PauseUnPauseOptions{}
+
+ containerUnpauseCommand = &cobra.Command{
+ Use: unpauseCommand.Use,
+ Short: unpauseCommand.Short,
+ Long: unpauseCommand.Long,
+ RunE: unpauseCommand.RunE,
+ Example: `podman container unpause ctrID
+ podman container unpause --all`,
+ }
)
+func unpauseFlags(flags *pflag.FlagSet) {
+ flags.BoolVarP(&unPauseOptions.All, "all", "a", false, "Pause all running containers")
+}
+
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: unpauseCommand,
- Parent: containerCmd,
})
flags := unpauseCommand.Flags()
- flags.BoolVarP(&unPauseOptions.All, "all", "a", false, "Pause all running containers")
+ unpauseFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: unpauseCommand,
+ Parent: containerCmd,
+ })
+
+ unpauseCommandFlags := containerUnpauseCommand.Flags()
+ unpauseFlags(unpauseCommandFlags)
}
func unpause(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/containers/wait.go b/cmd/podman/containers/wait.go
index 47f28f4c6..da746361d 100644
--- a/cmd/podman/containers/wait.go
+++ b/cmd/podman/containers/wait.go
@@ -11,6 +11,7 @@ import (
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -26,6 +27,16 @@ var (
podman wait --interval 5000 ctrID
podman wait ctrID1 ctrID2`,
}
+
+ containerWaitCommand = &cobra.Command{
+ Use: waitCommand.Use,
+ Short: waitCommand.Short,
+ Long: waitCommand.Long,
+ RunE: waitCommand.RunE,
+ Example: `podman container wait --latest
+ podman container wait --interval 5000 ctrID
+ podman container wait ctrID1 ctrID2`,
+ }
)
var (
@@ -33,13 +44,7 @@ var (
waitCondition string
)
-func init() {
- registry.Commands = append(registry.Commands, registry.CliCommand{
- Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: waitCommand,
- })
-
- flags := waitCommand.Flags()
+func waitFlags(flags *pflag.FlagSet) {
flags.DurationVarP(&waitOptions.Interval, "interval", "i", time.Duration(250), "Milliseconds to wait before polling for completion")
flags.BoolVarP(&waitOptions.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.StringVar(&waitCondition, "condition", "stopped", "Condition to wait on")
@@ -49,6 +54,24 @@ func init() {
}
}
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: waitCommand,
+ })
+ flags := waitCommand.Flags()
+ waitFlags(flags)
+
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: containerWaitCommand,
+ Parent: containerCmd,
+ })
+
+ containerWaitFlags := containerWaitCommand.Flags()
+ waitFlags(containerWaitFlags)
+}
+
func wait(cmd *cobra.Command, args []string) error {
var (
err error
diff --git a/cmd/podman/images/inspect.go b/cmd/podman/images/inspect.go
index 11bef02ba..3190ab725 100644
--- a/cmd/podman/images/inspect.go
+++ b/cmd/podman/images/inspect.go
@@ -84,10 +84,14 @@ func inspect(cmd *cobra.Command, args []string) error {
}
}
+ var lastErr error
for id, e := range results.Errors {
- fmt.Fprintf(os.Stderr, "%s: %s\n", id, e.Error())
+ if lastErr != nil {
+ fmt.Fprintf(os.Stderr, "%s: %s\n", id, lastErr.Error())
+ }
+ lastErr = e
}
- return nil
+ return lastErr
}
func inspectFormat(row string) string {
diff --git a/cmd/podman/images/rm.go b/cmd/podman/images/rm.go
index 135fda387..da6a90d2b 100644
--- a/cmd/podman/images/rm.go
+++ b/cmd/podman/images/rm.go
@@ -2,7 +2,6 @@ package images
import (
"fmt"
- "os"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/pkg/domain/entities"
@@ -23,7 +22,7 @@ var (
podman image rm c4dfb1609ee2 93fd78260bd1 c0ed59d05ff7`,
}
- imageOpts = entities.ImageDeleteOptions{}
+ imageOpts = entities.ImageRemoveOptions{}
)
func init() {
@@ -40,32 +39,25 @@ func imageRemoveFlagSet(flags *pflag.FlagSet) {
flags.BoolVarP(&imageOpts.All, "all", "a", false, "Remove all images")
flags.BoolVarP(&imageOpts.Force, "force", "f", false, "Force Removal of the image")
}
-func rm(cmd *cobra.Command, args []string) error {
+func rm(cmd *cobra.Command, args []string) error {
if len(args) < 1 && !imageOpts.All {
return errors.Errorf("image name or ID must be specified")
}
if len(args) > 0 && imageOpts.All {
return errors.Errorf("when using the --all switch, you may not pass any images names or IDs")
}
- report, err := registry.ImageEngine().Delete(registry.GetContext(), args, imageOpts)
- if err != nil {
- switch {
- case report != nil && report.ImageNotFound != nil:
- fmt.Fprintln(os.Stderr, err.Error())
- registry.SetExitCode(2)
- case report != nil && report.ImageInUse != nil:
- fmt.Fprintln(os.Stderr, err.Error())
- default:
- return err
+
+ report, err := registry.ImageEngine().Remove(registry.GetContext(), args, imageOpts)
+ if report != nil {
+ for _, u := range report.Untagged {
+ fmt.Println("Untagged: " + u)
}
+ for _, d := range report.Deleted {
+ fmt.Println("Deleted: " + d)
+ }
+ registry.SetExitCode(report.ExitCode)
}
- for _, u := range report.Untagged {
- fmt.Println("Untagged: " + u)
- }
- for _, d := range report.Deleted {
- fmt.Println("Deleted: " + d)
- }
- return nil
+ return err
}
diff --git a/cmd/podman/login.go b/cmd/podman/login.go
new file mode 100644
index 000000000..1843a764d
--- /dev/null
+++ b/cmd/podman/login.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "context"
+ "os"
+
+ "github.com/containers/common/pkg/auth"
+ "github.com/containers/image/v5/types"
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/spf13/cobra"
+)
+
+type loginOptionsWrapper struct {
+ auth.LoginOptions
+ tlsVerify bool
+}
+
+var (
+ loginOptions = loginOptionsWrapper{}
+ loginCommand = &cobra.Command{
+ Use: "login [flags] REGISTRY",
+ Short: "Login to a container registry",
+ Long: "Login to a container registry on a specified server.",
+ RunE: login,
+ Args: cobra.ExactArgs(1),
+ Example: `podman login quay.io
+ podman login --username ... --password ... quay.io
+ podman login --authfile dir/auth.json quay.io`,
+ }
+)
+
+func init() {
+ // Note that the local and the remote client behave the same: both
+ // store credentials locally while the remote client will pass them
+ // over the wire to the endpoint.
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: loginCommand,
+ })
+ flags := loginCommand.Flags()
+
+ // Flags from the auth package.
+ flags.AddFlagSet(auth.GetLoginFlags(&loginOptions.LoginOptions))
+
+ // Podman flags.
+ flags.BoolVarP(&loginOptions.tlsVerify, "tls-verify", "", false, "Require HTTPS and verify certificates when contacting registries")
+ flags.BoolVarP(&loginOptions.GetLoginSet, "get-login", "", false, "Return the current login user for the registry")
+ loginOptions.Stdin = os.Stdin
+ loginOptions.Stdout = os.Stdout
+}
+
+// Implementation of podman-login.
+func login(cmd *cobra.Command, args []string) error {
+ var skipTLS types.OptionalBool
+
+ if cmd.Flags().Changed("tls-verify") {
+ skipTLS = types.NewOptionalBool(!loginOptions.tlsVerify)
+ }
+
+ sysCtx := types.SystemContext{
+ AuthFilePath: loginOptions.AuthFile,
+ DockerCertPath: loginOptions.CertDir,
+ DockerInsecureSkipTLSVerify: skipTLS,
+ }
+
+ return auth.Login(context.Background(), &sysCtx, &loginOptions.LoginOptions, args[0])
+}
diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go
new file mode 100644
index 000000000..77bdc92b4
--- /dev/null
+++ b/cmd/podman/logout.go
@@ -0,0 +1,57 @@
+package main
+
+import (
+ "os"
+
+ "github.com/containers/common/pkg/auth"
+ "github.com/containers/image/v5/types"
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/pkg/errors"
+ "github.com/spf13/cobra"
+)
+
+var (
+ logoutOptions = auth.LogoutOptions{}
+ logoutCommand = &cobra.Command{
+ Use: "logout [flags] REGISTRY",
+ Short: "Logout of a container registry",
+ Long: "Remove the cached username and password for the registry.",
+ RunE: logout,
+ Args: cobra.MaximumNArgs(1),
+ Example: `podman logout quay.io
+ podman logout --authfile dir/auth.json quay.io
+ podman logout --all`,
+ }
+)
+
+func init() {
+ // Note that the local and the remote client behave the same: both
+ // store credentials locally while the remote client will pass them
+ // over the wire to the endpoint.
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: logoutCommand,
+ })
+ flags := logoutCommand.Flags()
+
+ // Flags from the auth package.
+ flags.AddFlagSet(auth.GetLogoutFlags(&logoutOptions))
+ logoutOptions.Stdin = os.Stdin
+ logoutOptions.Stdout = os.Stdout
+}
+
+// Implementation of podman-logout.
+func logout(cmd *cobra.Command, args []string) error {
+ sysCtx := types.SystemContext{AuthFilePath: logoutOptions.AuthFile}
+
+ registry := ""
+ if len(args) > 0 {
+ if logoutOptions.All {
+ return errors.New("--all takes no arguments")
+ }
+ registry = args[0]
+ }
+
+ return auth.Logout(&sysCtx, &logoutOptions, registry)
+}
diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go
index 63dab4707..647cf24b2 100644
--- a/cmd/podman/pods/create.go
+++ b/cmd/podman/pods/create.go
@@ -9,7 +9,6 @@ import (
"github.com/containers/libpod/cmd/podman/common"
"github.com/containers/libpod/cmd/podman/parse"
"github.com/containers/libpod/cmd/podman/registry"
- "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/errorhandling"
"github.com/containers/libpod/pkg/specgen"
@@ -50,8 +49,8 @@ func init() {
flags.AddFlagSet(common.GetNetFlags())
flags.StringVar(&createOptions.CGroupParent, "cgroup-parent", "", "Set parent cgroup for the pod")
flags.BoolVar(&createOptions.Infra, "infra", true, "Create an infra container associated with the pod to share namespaces with")
- flags.StringVar(&createOptions.InfraImage, "infra-image", define.DefaultInfraImage, "The image of the infra container to associate with the pod")
- flags.StringVar(&createOptions.InfraCommand, "infra-command", define.DefaultInfraCommand, "The command to run on the infra container when the pod is started")
+ flags.StringVar(&createOptions.InfraImage, "infra-image", containerConfig.Engine.InfraImage, "The image of the infra container to associate with the pod")
+ flags.StringVar(&createOptions.InfraCommand, "infra-command", containerConfig.Engine.InfraCommand, "The command to run on the infra container when the pod is started")
flags.StringSliceVar(&labelFile, "label-file", []string{}, "Read in a line delimited file of labels")
flags.StringSliceVarP(&labels, "label", "l", []string{}, "Set metadata on pod (default [])")
flags.StringVarP(&createOptions.Name, "name", "n", "", "Assign a name to the pod")
diff --git a/cmd/podman/pods/pod.go b/cmd/podman/pods/pod.go
index 1cac50e40..fa917b2ae 100644
--- a/cmd/podman/pods/pod.go
+++ b/cmd/podman/pods/pod.go
@@ -3,6 +3,7 @@ package pods
import (
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/util"
"github.com/spf13/cobra"
)
@@ -15,6 +16,7 @@ var (
TraverseChildren: true,
RunE: registry.SubCommandExists,
}
+ containerConfig = util.DefaultContainerConfig()
)
func init() {
diff --git a/cmd/podman/pods/stop.go b/cmd/podman/pods/stop.go
index 683d9c00a..daf05d640 100644
--- a/cmd/podman/pods/stop.go
+++ b/cmd/podman/pods/stop.go
@@ -47,11 +47,10 @@ func init() {
flags.BoolVarP(&stopOptions.All, "all", "a", false, "Stop all running pods")
flags.BoolVarP(&stopOptions.Ignore, "ignore", "i", false, "Ignore errors when a specified pod is missing")
flags.BoolVarP(&stopOptions.Latest, "latest", "l", false, "Stop the latest pod podman is aware of")
- flags.UintVarP(&timeout, "time", "t", 0, "Seconds to wait for pod stop before killing the container")
+ flags.UintVarP(&timeout, "time", "t", containerConfig.Engine.StopTimeout, "Seconds to wait for pod stop before killing the container")
if registry.IsRemote() {
_ = flags.MarkHidden("latest")
_ = flags.MarkHidden("ignore")
-
}
flags.SetNormalizeFunc(utils.AliasFlags)
}
diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go
index e09107b53..f4b91dd78 100644
--- a/cmd/podman/system/service.go
+++ b/cmd/podman/system/service.go
@@ -90,7 +90,8 @@ func service(cmd *cobra.Command, args []string) error {
logrus.Warn("This function is EXPERIMENTAL")
fmt.Fprintf(os.Stderr, "This function is EXPERIMENTAL.\n")
- return registry.ContainerEngine().RestService(registry.GetContext(), opts)
+
+ return restService(opts, cmd.Flags(), registry.PodmanConfig())
}
func resolveApiURI(_url []string) (string, error) {
diff --git a/cmd/podman/system/service_abi.go b/cmd/podman/system/service_abi.go
new file mode 100644
index 000000000..3da6ccfc7
--- /dev/null
+++ b/cmd/podman/system/service_abi.go
@@ -0,0 +1,57 @@
+// +build ABISupport
+
+package system
+
+import (
+ "context"
+ "net"
+ "strings"
+
+ api "github.com/containers/libpod/pkg/api/server"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/domain/infra"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+ "github.com/spf13/pflag"
+)
+
+func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entities.PodmanConfig) error {
+ var (
+ listener *net.Listener
+ err error
+ )
+
+ if opts.URI != "" {
+ fields := strings.Split(opts.URI, ":")
+ if len(fields) == 1 {
+ return errors.Errorf("%s is an invalid socket destination", opts.URI)
+ }
+ address := strings.Join(fields[1:], ":")
+ l, err := net.Listen(fields[0], address)
+ if err != nil {
+ return errors.Wrapf(err, "unable to create socket %s", opts.URI)
+ }
+ listener = &l
+ }
+
+ rt, err := infra.GetRuntime(context.Background(), flags, cfg)
+ if err != nil {
+ return err
+ }
+
+ server, err := api.NewServerWithSettings(rt, opts.Timeout, listener)
+ if err != nil {
+ return err
+ }
+ defer func() {
+ if err := server.Shutdown(); err != nil {
+ logrus.Warnf("Error when stopping API service: %s", err)
+ }
+ }()
+
+ err = server.Serve()
+ if listener != nil {
+ _ = (*listener).Close()
+ }
+ return err
+}
diff --git a/cmd/podman/system/service_unsupported.go b/cmd/podman/system/service_unsupported.go
new file mode 100644
index 000000000..95f8189f6
--- /dev/null
+++ b/cmd/podman/system/service_unsupported.go
@@ -0,0 +1,14 @@
+// +build !ABISupport
+
+package system
+
+import (
+ "errors"
+
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/spf13/pflag"
+)
+
+func restService(opts entities.ServiceOptions, flags *pflag.FlagSet, cfg *entities.PodmanConfig) error {
+ return errors.New("not supported")
+}
diff --git a/cmd/podman/volumes/create.go b/cmd/podman/volumes/create.go
index df0731791..1bec8d0e7 100644
--- a/cmd/podman/volumes/create.go
+++ b/cmd/podman/volumes/create.go
@@ -40,7 +40,7 @@ func init() {
Parent: volumeCmd,
})
flags := createCommand.Flags()
- flags.StringVar(&createOpts.Driver, "driver", "", "Specify volume driver name (default local)")
+ flags.StringVar(&createOpts.Driver, "driver", "local", "Specify volume driver name")
flags.StringSliceVarP(&opts.Label, "label", "l", []string{}, "Set metadata for a volume (default [])")
flags.StringArrayVarP(&opts.Opts, "opt", "o", []string{}, "Set driver specific options (default [])")
}