summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/create.go12
-rw-r--r--cmd/podman/common/create_opts.go2
-rw-r--r--cmd/podman/common/specgen.go34
-rw-r--r--cmd/podman/containers/create.go29
-rw-r--r--cmd/podman/containers/inspect.go8
-rw-r--r--cmd/podman/images/inspect.go5
-rw-r--r--cmd/podman/root.go11
7 files changed, 48 insertions, 53 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index 7086dc839..86cd51643 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -50,7 +50,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"Drop capabilities from the container",
)
createFlags.String(
- "cgroupns", containerConfig.CgroupNS(),
+ "cgroupns", "",
"cgroup namespace to use",
)
createFlags.StringVar(
@@ -244,7 +244,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"Keep STDIN open even if not attached",
)
createFlags.String(
- "ipc", containerConfig.IPCNS(),
+ "ipc", "",
"IPC namespace to use",
)
createFlags.StringVar(
@@ -325,7 +325,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
)
// markFlagHidden(createFlags, "override-os")
createFlags.String(
- "pid", containerConfig.PidNS(),
+ "pid", "",
"PID namespace to use",
)
createFlags.Int64Var(
@@ -424,7 +424,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"Sysctl options",
)
createFlags.StringVar(
- &cf.SystemdD,
+ &cf.Systemd,
"systemd", "true",
`Run container in systemd mode ("true"|"false"|"always")`,
)
@@ -454,11 +454,11 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"Username or UID (format: <name|uid>[:<group|gid>])",
)
createFlags.String(
- "userns", containerConfig.Containers.UserNS,
+ "userns", "",
"User namespace to use",
)
createFlags.String(
- "uts", containerConfig.Containers.UTSNS,
+ "uts", "",
"UTS namespace to use",
)
createFlags.StringArrayVar(
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 8b38e3b47..4cba5daf7 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -85,7 +85,7 @@ type ContainerCLIOpts struct {
SubUIDName string
SubGIDName string
Sysctl []string
- SystemdD string
+ Systemd string
TmpFS []string
TTY bool
UIDMap []string
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 1fabff378..26003b40f 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -3,7 +3,6 @@ package common
import (
"fmt"
"os"
- "path/filepath"
"strconv"
"strings"
"time"
@@ -285,16 +284,13 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
s.NetNS = c.Net.Network
}
- // STOP SIGNAL
- signalString := "TERM"
if sig := c.StopSignal; len(sig) > 0 {
- signalString = sig
- }
- stopSignal, err := util.ParseSignal(signalString)
- if err != nil {
- return err
+ stopSignal, err := util.ParseSignal(sig)
+ if err != nil {
+ return err
+ }
+ s.StopSignal = &stopSignal
}
- s.StopSignal = &stopSignal
// ENVIRONMENT VARIABLES
//
@@ -439,25 +435,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
s.ImageVolumeMode = "anonymous"
}
- systemd := c.SystemdD == "always"
- if !systemd && command != nil {
- x, err := strconv.ParseBool(c.SystemdD)
- if err != nil {
- return errors.Wrapf(err, "cannot parse bool %s", c.SystemdD)
- }
- if x && (command[0] == "/usr/sbin/init" || command[0] == "/sbin/init" || (filepath.Base(command[0]) == "systemd")) {
- systemd = true
- }
- }
- if systemd {
- if s.StopSignal == nil {
- stopSignal, err = util.ParseSignal("RTMIN+3")
- if err != nil {
- return errors.Wrapf(err, "error parsing systemd signal")
- }
- s.StopSignal = &stopSignal
- }
- }
+ s.Systemd = c.Systemd
if s.ResourceLimits == nil {
s.ResourceLimits = &specs.LinuxResources{}
}
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index c8007bc2f..ed09585ba 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -161,24 +161,25 @@ func createInit(c *cobra.Command) error {
if c.Flag("no-hosts").Changed && c.Flag("add-host").Changed {
return errors.Errorf("--no-hosts and --add-host cannot be set together")
}
- if c.Flag("userns").Changed {
- cliVals.UserNS = c.Flag("userns").Value.String()
- }
- if c.Flag("ipc").Changed {
- cliVals.IPC = c.Flag("ipc").Value.String()
- }
- if c.Flag("uts").Changed {
- cliVals.UTS = c.Flag("uts").Value.String()
- }
- if c.Flag("pid").Changed {
- cliVals.PID = c.Flag("pid").Value.String()
+ cliVals.UserNS = c.Flag("userns").Value.String()
+ // if user did not modify --userns flag and did turn on
+ // uid/gid mappsings, set userns flag to "private"
+ if !c.Flag("userns").Changed && cliVals.UserNS == "host" {
+ if len(cliVals.UIDMap) > 0 ||
+ len(cliVals.GIDMap) > 0 ||
+ cliVals.SubUIDName != "" ||
+ cliVals.SubGIDName != "" {
+ cliVals.UserNS = "private"
+ }
}
+
+ cliVals.IPC = c.Flag("ipc").Value.String()
+ cliVals.UTS = c.Flag("uts").Value.String()
+ cliVals.PID = c.Flag("pid").Value.String()
+ cliVals.CGroupsNS = c.Flag("cgroupns").Value.String()
if !c.Flag("pids-limit").Changed {
cliVals.PIDsLimit = -1
}
- if c.Flag("cgroupns").Changed {
- cliVals.CGroupsNS = c.Flag("cgroupns").Value.String()
- }
if c.Flag("entrypoint").Changed {
val := c.Flag("entrypoint").Value.String()
cliVals.Entrypoint = &val
diff --git a/cmd/podman/containers/inspect.go b/cmd/podman/containers/inspect.go
index 4549a4ef6..8556ebe83 100644
--- a/cmd/podman/containers/inspect.go
+++ b/cmd/podman/containers/inspect.go
@@ -26,9 +26,15 @@ func init() {
Command: inspectCmd,
Parent: containerCmd,
})
- inspectOpts = inspect.AddInspectFlagSet(inspectCmd)
+ inspectOpts = new(entities.InspectOptions)
+ flags := inspectCmd.Flags()
+ flags.BoolVarP(&inspectOpts.Size, "size", "s", false, "Display total file size")
+ flags.StringVarP(&inspectOpts.Format, "format", "f", "json", "Format the output to a Go template or json")
+ flags.BoolVarP(&inspectOpts.Latest, "latest", "l", false, "Act on the latest container Podman is aware of")
}
func inspectExec(cmd *cobra.Command, args []string) error {
+ // Force container type
+ inspectOpts.Type = inspect.ContainerType
return inspect.Inspect(args, *inspectOpts)
}
diff --git a/cmd/podman/images/inspect.go b/cmd/podman/images/inspect.go
index 8c727eb07..f6a10ba44 100644
--- a/cmd/podman/images/inspect.go
+++ b/cmd/podman/images/inspect.go
@@ -27,11 +27,12 @@ func init() {
Command: inspectCmd,
Parent: imageCmd,
})
- inspectOpts = inspect.AddInspectFlagSet(inspectCmd)
+ inspectOpts = new(entities.InspectOptions)
flags := inspectCmd.Flags()
- _ = flags.MarkHidden("latest") // Shared with container-inspect but not wanted here.
+ flags.StringVarP(&inspectOpts.Format, "format", "f", "json", "Format the output to a Go template or json")
}
func inspectExec(cmd *cobra.Command, args []string) error {
+ inspectOpts.Type = inspect.ImageType
return inspect.Inspect(args, *inspectOpts)
}
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 59d536d0b..b62ee144a 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -4,12 +4,14 @@ import (
"fmt"
"os"
"path"
+ "runtime"
"runtime/pprof"
"strings"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/cmd/podman/validate"
"github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/parallel"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/tracing"
"github.com/containers/libpod/version"
@@ -137,6 +139,13 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
opentracing.StartSpanFromContext(cfg.SpanCtx, cmd.Name())
}
+ if cfg.MaxWorks <= 0 {
+ return errors.Errorf("maximum workers must be set to a positive number (got %d)", cfg.MaxWorks)
+ }
+ if err := parallel.SetMaxThreads(uint(cfg.MaxWorks)); err != nil {
+ return err
+ }
+
// Setup Rootless environment, IFF:
// 1) in ABI mode
// 2) running as non-root
@@ -216,7 +225,7 @@ func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) {
flags.StringVar(&cfg.Containers.DefaultMountsFile, "default-mounts-file", cfg.Containers.DefaultMountsFile, "Path to default mounts file")
flags.StringVar(&cfg.Engine.EventsLogger, "events-backend", cfg.Engine.EventsLogger, `Events backend to use ("file"|"journald"|"none")`)
flags.StringSliceVar(&cfg.Engine.HooksDir, "hooks-dir", cfg.Engine.HooksDir, "Set the OCI hooks directory path (may be set multiple times)")
- flags.IntVar(&opts.MaxWorks, "max-workers", 0, "The maximum number of workers for parallel operations")
+ flags.IntVar(&opts.MaxWorks, "max-workers", (runtime.NumCPU()*3)+1, "The maximum number of workers for parallel operations")
flags.StringVar(&cfg.Engine.Namespace, "namespace", cfg.Engine.Namespace, "Set the libpod namespace, used to create separate views of the containers and pods on the system")
flags.StringVar(&cfg.Engine.StaticDir, "root", "", "Path to the root directory in which data, including images, is stored")
flags.StringVar(&opts.RegistriesConf, "registries-conf", "", "Path to a registries.conf to use for image processing")