diff options
99 files changed, 184 insertions, 125 deletions
diff --git a/cmd/podman/attach.go b/cmd/podman/attach.go index 2fa05a3b1..c07c0f1cf 100644 --- a/cmd/podman/attach.go +++ b/cmd/podman/attach.go @@ -17,6 +17,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { attachCommand.InputArgs = args attachCommand.GlobalFlags = MainGlobalOpts + attachCommand.Remote = remoteclient return attachCmd(&attachCommand) }, Example: `podman attach ctrID diff --git a/cmd/podman/build.go b/cmd/podman/build.go index f0a67791a..b69ac6e84 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -39,6 +39,7 @@ var ( buildCommand.FromAndBudResults = &fromAndBudValues buildCommand.LayerResults = &layerValues buildCommand.NameSpaceResults = &namespaceValues + buildCommand.Remote = remoteclient return buildCmd(&buildCommand) }, Example: `podman build . diff --git a/cmd/podman/checkpoint.go b/cmd/podman/checkpoint.go index 5b8d00ff9..f2f5d37da 100644 --- a/cmd/podman/checkpoint.go +++ b/cmd/podman/checkpoint.go @@ -23,6 +23,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { checkpointCommand.InputArgs = args checkpointCommand.GlobalFlags = MainGlobalOpts + checkpointCommand.Remote = remoteclient return checkpointCmd(&checkpointCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/cleanup.go b/cmd/podman/cleanup.go index 17e637da1..f5b3cf55b 100644 --- a/cmd/podman/cleanup.go +++ b/cmd/podman/cleanup.go @@ -24,6 +24,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { cleanupCommand.InputArgs = args cleanupCommand.GlobalFlags = MainGlobalOpts + cleanupCommand.Remote = remoteclient return cleanupCmd(&cleanupCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/cliconfig/commands.go b/cmd/podman/cliconfig/commands.go index 00b66e32a..f6d92611f 100644 --- a/cmd/podman/cliconfig/commands.go +++ b/cmd/podman/cliconfig/commands.go @@ -26,7 +26,9 @@ func (p *PodmanCommand) IsSet(opt string) bool { func (p *PodmanCommand) Bool(opt string) bool { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return false } val, err := p.Flags().GetBool(opt) @@ -40,7 +42,9 @@ func (p *PodmanCommand) Bool(opt string) bool { func (p *PodmanCommand) String(opt string) string { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return "" } val, err := p.Flags().GetString(opt) @@ -54,7 +58,9 @@ func (p *PodmanCommand) String(opt string) string { func (p *PodmanCommand) StringArray(opt string) []string { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return []string{} } val, err := p.Flags().GetStringArray(opt) @@ -68,7 +74,9 @@ func (p *PodmanCommand) StringArray(opt string) []string { func (p *PodmanCommand) StringSlice(opt string) []string { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return []string{} } val, err := p.Flags().GetStringSlice(opt) @@ -82,7 +90,9 @@ func (p *PodmanCommand) StringSlice(opt string) []string { func (p *PodmanCommand) Int(opt string) int { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return 0 } val, err := p.Flags().GetInt(opt) @@ -96,7 +106,9 @@ func (p *PodmanCommand) Int(opt string) int { func (p *PodmanCommand) Uint(opt string) uint { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return 0 } val, err := p.Flags().GetUint(opt) @@ -110,7 +122,9 @@ func (p *PodmanCommand) Uint(opt string) uint { func (p *PodmanCommand) Int64(opt string) int64 { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return 0 } val, err := p.Flags().GetInt64(opt) @@ -124,7 +138,9 @@ func (p *PodmanCommand) Int64(opt string) int64 { func (p *PodmanCommand) Uint64(opt string) uint64 { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return 0 } val, err := p.Flags().GetUint64(opt) @@ -138,7 +154,9 @@ func (p *PodmanCommand) Uint64(opt string) uint64 { func (p *PodmanCommand) Float64(opt string) float64 { flag := p.Flags().Lookup(opt) if flag == nil { - logrus.Errorf("Could not find flag %s", opt) + if !p.Remote { + logrus.Errorf("Could not find flag %s", opt) + } return 0 } val, err := p.Flags().GetFloat64(opt) diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go index 2692ace36..982c77c17 100644 --- a/cmd/podman/cliconfig/config.go +++ b/cmd/podman/cliconfig/config.go @@ -8,6 +8,7 @@ type PodmanCommand struct { *cobra.Command InputArgs []string GlobalFlags MainFlags + Remote bool } type MainFlags struct { diff --git a/cmd/podman/commit.go b/cmd/podman/commit.go index 0077ff297..5963f8686 100644 --- a/cmd/podman/commit.go +++ b/cmd/podman/commit.go @@ -28,6 +28,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { commitCommand.InputArgs = args commitCommand.GlobalFlags = MainGlobalOpts + commitCommand.Remote = remoteclient return commitCmd(&commitCommand) }, Example: `podman commit -q --message "committing container to image" reverent_golick image-commited diff --git a/cmd/podman/containers_prune.go b/cmd/podman/containers_prune.go index 39be70c5b..abc56cee1 100644 --- a/cmd/podman/containers_prune.go +++ b/cmd/podman/containers_prune.go @@ -27,6 +27,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { pruneContainersCommand.InputArgs = args pruneContainersCommand.GlobalFlags = MainGlobalOpts + pruneContainersCommand.Remote = remoteclient return pruneContainersCmd(&pruneContainersCommand) }, } diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go index 7dee37287..6e48b9f3b 100644 --- a/cmd/podman/cp.go +++ b/cmd/podman/cp.go @@ -36,6 +36,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { cpCommand.InputArgs = args cpCommand.GlobalFlags = MainGlobalOpts + cpCommand.Remote = remoteclient return cpCmd(&cpCommand) }, Example: "[CONTAINER:]SRC_PATH [CONTAINER:]DEST_PATH", diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 3267e5b7b..cfc0fa0c3 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { createCommand.InputArgs = args createCommand.GlobalFlags = MainGlobalOpts + createCommand.Remote = remoteclient return createCmd(&createCommand) }, Example: `podman create alpine ls diff --git a/cmd/podman/diff.go b/cmd/podman/diff.go index 7f5a313f8..1138c48a3 100644 --- a/cmd/podman/diff.go +++ b/cmd/podman/diff.go @@ -43,6 +43,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { diffCommand.InputArgs = args diffCommand.GlobalFlags = MainGlobalOpts + diffCommand.Remote = remoteclient return diffCmd(&diffCommand) }, Example: `podman diff imageID diff --git a/cmd/podman/events.go b/cmd/podman/events.go index f6c20e8ff..4c11fe1f3 100644 --- a/cmd/podman/events.go +++ b/cmd/podman/events.go @@ -18,6 +18,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { eventsCommand.InputArgs = args eventsCommand.GlobalFlags = MainGlobalOpts + eventsCommand.Remote = remoteclient return eventsCmd(&eventsCommand) }, Example: `podman events diff --git a/cmd/podman/exec.go b/cmd/podman/exec.go index f720a9aff..d0d88ee8b 100644 --- a/cmd/podman/exec.go +++ b/cmd/podman/exec.go @@ -26,6 +26,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { execCommand.InputArgs = args execCommand.GlobalFlags = MainGlobalOpts + execCommand.Remote = remoteclient return execCmd(&execCommand) }, Example: `podman exec -it ctrID ls diff --git a/cmd/podman/exists.go b/cmd/podman/exists.go index 8a2f78c88..dae48f14b 100644 --- a/cmd/podman/exists.go +++ b/cmd/podman/exists.go @@ -29,6 +29,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { imageExistsCommand.InputArgs = args imageExistsCommand.GlobalFlags = MainGlobalOpts + imageExistsCommand.Remote = remoteclient return imageExistsCmd(&imageExistsCommand) }, Example: `podman image exists imageID @@ -42,6 +43,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { containerExistsCommand.InputArgs = args containerExistsCommand.GlobalFlags = MainGlobalOpts + containerExistsCommand.Remote = remoteclient return containerExistsCmd(&containerExistsCommand) }, @@ -56,6 +58,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podExistsCommand.InputArgs = args podExistsCommand.GlobalFlags = MainGlobalOpts + podExistsCommand.Remote = remoteclient return podExistsCmd(&podExistsCommand) }, Example: `podman pod exists podID diff --git a/cmd/podman/export.go b/cmd/podman/export.go index db031aaf2..004c3ccde 100644 --- a/cmd/podman/export.go +++ b/cmd/podman/export.go @@ -23,6 +23,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { exportCommand.InputArgs = args exportCommand.GlobalFlags = MainGlobalOpts + exportCommand.Remote = remoteclient return exportCmd(&exportCommand) }, Example: `podman export ctrID > myCtr.tar diff --git a/cmd/podman/generate_kube.go b/cmd/podman/generate_kube.go index 30818403b..7963cde6e 100644 --- a/cmd/podman/generate_kube.go +++ b/cmd/podman/generate_kube.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { containerKubeCommand.InputArgs = args containerKubeCommand.GlobalFlags = MainGlobalOpts + containerKubeCommand.Remote = remoteclient return generateKubeYAMLCmd(&containerKubeCommand) }, Example: `podman generate kube ctrID diff --git a/cmd/podman/healthcheck_run.go b/cmd/podman/healthcheck_run.go index bd3a4ea15..832451e0c 100644 --- a/cmd/podman/healthcheck_run.go +++ b/cmd/podman/healthcheck_run.go @@ -20,6 +20,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { healthcheckRunCommand.InputArgs = args healthcheckRunCommand.GlobalFlags = MainGlobalOpts + healthcheckRunCommand.Remote = remoteclient return healthCheckCmd(&healthcheckRunCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/history.go b/cmd/podman/history.go index 4b76ef0ca..f96d7934c 100644 --- a/cmd/podman/history.go +++ b/cmd/podman/history.go @@ -47,6 +47,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { historyCommand.InputArgs = args historyCommand.GlobalFlags = MainGlobalOpts + historyCommand.Remote = remoteclient return historyCmd(&historyCommand) }, } diff --git a/cmd/podman/images.go b/cmd/podman/images.go index c38d7035d..f584c1131 100644 --- a/cmd/podman/images.go +++ b/cmd/podman/images.go @@ -96,6 +96,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { imagesCommand.InputArgs = args imagesCommand.GlobalFlags = MainGlobalOpts + imagesCommand.Remote = remoteclient return imagesCmd(&imagesCommand) }, Example: `podman images --format json diff --git a/cmd/podman/images_prune.go b/cmd/podman/images_prune.go index b6f335fb3..84181d0a2 100644 --- a/cmd/podman/images_prune.go +++ b/cmd/podman/images_prune.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { pruneImagesCommand.InputArgs = args pruneImagesCommand.GlobalFlags = MainGlobalOpts + pruneImagesCommand.Remote = remoteclient return pruneImagesCmd(&pruneImagesCommand) }, } diff --git a/cmd/podman/import.go b/cmd/podman/import.go index f3fb7c988..2bba6cb0c 100644 --- a/cmd/podman/import.go +++ b/cmd/podman/import.go @@ -24,6 +24,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { importCommand.InputArgs = args importCommand.GlobalFlags = MainGlobalOpts + importCommand.Remote = remoteclient return importCmd(&importCommand) }, Example: `podman import http://example.com/ctr.tar url-image diff --git a/cmd/podman/info.go b/cmd/podman/info.go index 195267c7f..2b6ae1882 100644 --- a/cmd/podman/info.go +++ b/cmd/podman/info.go @@ -28,6 +28,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { infoCommand.InputArgs = args infoCommand.GlobalFlags = MainGlobalOpts + infoCommand.Remote = remoteclient return infoCmd(&infoCommand) }, Example: `podman info`, diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go index 528320170..9491bc7c7 100644 --- a/cmd/podman/inspect.go +++ b/cmd/podman/inspect.go @@ -33,6 +33,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { inspectCommand.InputArgs = args inspectCommand.GlobalFlags = MainGlobalOpts + inspectCommand.Remote = remoteclient return inspectCmd(&inspectCommand) }, Example: `podman inspect alpine diff --git a/cmd/podman/kill.go b/cmd/podman/kill.go index 20142e0bf..0513a154f 100644 --- a/cmd/podman/kill.go +++ b/cmd/podman/kill.go @@ -20,6 +20,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { killCommand.InputArgs = args killCommand.GlobalFlags = MainGlobalOpts + killCommand.Remote = remoteclient return killCmd(&killCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/libpodruntime/runtime.go b/cmd/podman/libpodruntime/runtime.go index 3faea493c..78adf1252 100644 --- a/cmd/podman/libpodruntime/runtime.go +++ b/cmd/podman/libpodruntime/runtime.go @@ -64,6 +64,10 @@ func getRuntime(c *cliconfig.PodmanCommand, renumber bool) (*libpod.Runtime, err storageOpts.GraphDriverOptions = c.GlobalFlags.StorageOpts } + if renumber { + options = append(options, libpod.WithRenumber()) + } + // Only set this if the user changes storage config on the command line if storageSet { options = append(options, libpod.WithStorageConfig(storageOpts)) diff --git a/cmd/podman/load.go b/cmd/podman/load.go index 04ff9fcca..3cc5e67c7 100644 --- a/cmd/podman/load.go +++ b/cmd/podman/load.go @@ -27,6 +27,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { loadCommand.InputArgs = args loadCommand.GlobalFlags = MainGlobalOpts + loadCommand.Remote = remoteclient return loadCmd(&loadCommand) }, } diff --git a/cmd/podman/login.go b/cmd/podman/login.go index 8a1687278..589255683 100644 --- a/cmd/podman/login.go +++ b/cmd/podman/login.go @@ -27,6 +27,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { loginCommand.InputArgs = args loginCommand.GlobalFlags = MainGlobalOpts + loginCommand.Remote = remoteclient return loginCmd(&loginCommand) }, Example: `podman login -u testuser -p testpassword localhost:5000 diff --git a/cmd/podman/logout.go b/cmd/podman/logout.go index 069153e0b..8abe918b8 100644 --- a/cmd/podman/logout.go +++ b/cmd/podman/logout.go @@ -20,6 +20,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { logoutCommand.InputArgs = args logoutCommand.GlobalFlags = MainGlobalOpts + logoutCommand.Remote = remoteclient return logoutCmd(&logoutCommand) }, Example: `podman logout docker.io diff --git a/cmd/podman/logs.go b/cmd/podman/logs.go index a1b5fb4cc..6f24dc8fb 100644 --- a/cmd/podman/logs.go +++ b/cmd/podman/logs.go @@ -24,6 +24,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { logsCommand.InputArgs = args logsCommand.GlobalFlags = MainGlobalOpts + logsCommand.Remote = remoteclient return logsCmd(&logsCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go index e008a4617..91ad42630 100644 --- a/cmd/podman/main_local.go +++ b/cmd/podman/main_local.go @@ -103,13 +103,14 @@ func profileOff(cmd *cobra.Command) error { } func setupRootless(cmd *cobra.Command, args []string) error { - if os.Geteuid() == 0 || cmd == _searchCommand || cmd == _versionCommand || strings.HasPrefix(cmd.Use, "help") { + if os.Geteuid() == 0 || cmd == _searchCommand || cmd == _versionCommand || cmd == _mountCommand || strings.HasPrefix(cmd.Use, "help") { return nil } podmanCmd := cliconfig.PodmanCommand{ cmd, args, MainGlobalOpts, + remoteclient, } runtime, err := libpodruntime.GetRuntime(&podmanCmd) if err != nil { diff --git a/cmd/podman/mount.go b/cmd/podman/mount.go index a70684a39..2ade8949a 100644 --- a/cmd/podman/mount.go +++ b/cmd/podman/mount.go @@ -31,6 +31,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { mountCommand.InputArgs = args mountCommand.GlobalFlags = MainGlobalOpts + mountCommand.Remote = remoteclient return mountCmd(&mountCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/pause.go b/cmd/podman/pause.go index fa4648128..3e6d36571 100644 --- a/cmd/podman/pause.go +++ b/cmd/podman/pause.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { pauseCommand.InputArgs = args pauseCommand.GlobalFlags = MainGlobalOpts + pauseCommand.Remote = remoteclient return pauseCmd(&pauseCommand) }, Example: `podman pause mywebserver diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go index 982e12d44..d60c873f8 100644 --- a/cmd/podman/play_kube.go +++ b/cmd/podman/play_kube.go @@ -44,6 +44,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { playKubeCommand.InputArgs = args playKubeCommand.GlobalFlags = MainGlobalOpts + playKubeCommand.Remote = remoteclient return playKubeYAMLCmd(&playKubeCommand) }, Example: `podman play kube demo.yml @@ -254,7 +255,6 @@ func getPodPorts(containers []v1.Container) []ocicni.PortMapping { func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container, runtime *libpod.Runtime, newImage *image.Image, namespaces map[string]string, volumes map[string]string) (*createconfig.CreateConfig, error) { var ( containerConfig createconfig.CreateConfig - envs map[string]string ) // The default for MemorySwappiness is -1, not 0 @@ -316,9 +316,10 @@ func kubeContainerToCreateConfig(ctx context.Context, containerYAML v1.Container if len(containerConfig.WorkDir) == 0 { containerConfig.WorkDir = "/" } - if len(containerYAML.Env) > 0 { - envs = make(map[string]string) - } + + // Set default environment variables and incorporate data from image, if necessary + envs := shared.EnvVariablesFromData(imageData) + // Environment Variables for _, e := range containerYAML.Env { envs[e.Name] = e.Value diff --git a/cmd/podman/pod_create.go b/cmd/podman/pod_create.go index 2f7a6b415..551010dce 100644 --- a/cmd/podman/pod_create.go +++ b/cmd/podman/pod_create.go @@ -30,6 +30,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podCreateCommand.InputArgs = args podCreateCommand.GlobalFlags = MainGlobalOpts + podCreateCommand.Remote = remoteclient return podCreateCmd(&podCreateCommand) }, } diff --git a/cmd/podman/pod_inspect.go b/cmd/podman/pod_inspect.go index e12678354..eb2366031 100644 --- a/cmd/podman/pod_inspect.go +++ b/cmd/podman/pod_inspect.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podInspectCommand.InputArgs = args podInspectCommand.GlobalFlags = MainGlobalOpts + podInspectCommand.Remote = remoteclient return podInspectCmd(&podInspectCommand) }, Example: `podman pod inspect podID`, diff --git a/cmd/podman/pod_kill.go b/cmd/podman/pod_kill.go index ebd7db762..145d0492f 100644 --- a/cmd/podman/pod_kill.go +++ b/cmd/podman/pod_kill.go @@ -24,6 +24,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podKillCommand.InputArgs = args podKillCommand.GlobalFlags = MainGlobalOpts + podKillCommand.Remote = remoteclient return podKillCmd(&podKillCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/pod_pause.go b/cmd/podman/pod_pause.go index ff29e0e1d..1c6611ebc 100644 --- a/cmd/podman/pod_pause.go +++ b/cmd/podman/pod_pause.go @@ -21,6 +21,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podPauseCommand.InputArgs = args podPauseCommand.GlobalFlags = MainGlobalOpts + podPauseCommand.Remote = remoteclient return podPauseCmd(&podPauseCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/pod_ps.go b/cmd/podman/pod_ps.go index a956882cf..f4b7437eb 100644 --- a/cmd/podman/pod_ps.go +++ b/cmd/podman/pod_ps.go @@ -127,6 +127,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podPsCommand.InputArgs = args podPsCommand.GlobalFlags = MainGlobalOpts + podPsCommand.Remote = remoteclient return podPsCmd(&podPsCommand) }, } diff --git a/cmd/podman/pod_restart.go b/cmd/podman/pod_restart.go index 0765b98db..519568974 100644 --- a/cmd/podman/pod_restart.go +++ b/cmd/podman/pod_restart.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podRestartCommand.InputArgs = args podRestartCommand.GlobalFlags = MainGlobalOpts + podRestartCommand.Remote = remoteclient return podRestartCmd(&podRestartCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/pod_rm.go b/cmd/podman/pod_rm.go index cd9f23fe1..dd67bb0e0 100644 --- a/cmd/podman/pod_rm.go +++ b/cmd/podman/pod_rm.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podRmCommand.InputArgs = args podRmCommand.GlobalFlags = MainGlobalOpts + podRmCommand.Remote = remoteclient return podRmCmd(&podRmCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/pod_start.go b/cmd/podman/pod_start.go index 949af80d8..104f9ad73 100644 --- a/cmd/podman/pod_start.go +++ b/cmd/podman/pod_start.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podStartCommand.InputArgs = args podStartCommand.GlobalFlags = MainGlobalOpts + podStartCommand.Remote = remoteclient return podStartCmd(&podStartCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/pod_stats.go b/cmd/podman/pod_stats.go index 36b0b95ed..ed59d9a61 100644 --- a/cmd/podman/pod_stats.go +++ b/cmd/podman/pod_stats.go @@ -29,6 +29,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podStatsCommand.InputArgs = args podStatsCommand.GlobalFlags = MainGlobalOpts + podStatsCommand.Remote = remoteclient return podStatsCmd(&podStatsCommand) }, Example: `podman stats -a --no-stream diff --git a/cmd/podman/pod_stop.go b/cmd/podman/pod_stop.go index f1b0ac51f..9cd425c29 100644 --- a/cmd/podman/pod_stop.go +++ b/cmd/podman/pod_stop.go @@ -23,6 +23,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podStopCommand.InputArgs = args podStopCommand.GlobalFlags = MainGlobalOpts + podStopCommand.Remote = remoteclient return podStopCmd(&podStopCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/pod_top.go b/cmd/podman/pod_top.go index 0d74dc3d6..e997d1456 100644 --- a/cmd/podman/pod_top.go +++ b/cmd/podman/pod_top.go @@ -28,6 +28,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podTopCommand.InputArgs = args podTopCommand.GlobalFlags = MainGlobalOpts + podTopCommand.Remote = remoteclient return podTopCmd(&podTopCommand) }, Example: `podman top ctrID diff --git a/cmd/podman/pod_unpause.go b/cmd/podman/pod_unpause.go index 0623c6abb..15375bee9 100644 --- a/cmd/podman/pod_unpause.go +++ b/cmd/podman/pod_unpause.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { podUnpauseCommand.InputArgs = args podUnpauseCommand.GlobalFlags = MainGlobalOpts + podUnpauseCommand.Remote = remoteclient return podUnpauseCmd(&podUnpauseCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/port.go b/cmd/podman/port.go index b5a4d3eec..d63ae4aa9 100644 --- a/cmd/podman/port.go +++ b/cmd/podman/port.go @@ -23,6 +23,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { portCommand.InputArgs = args portCommand.GlobalFlags = MainGlobalOpts + portCommand.Remote = remoteclient return portCmd(&portCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index 5bb88f227..a9e46d6b9 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -161,6 +161,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { psCommand.InputArgs = args psCommand.GlobalFlags = MainGlobalOpts + psCommand.Remote = remoteclient return psCmd(&psCommand) }, Example: `podman ps -a diff --git a/cmd/podman/pull.go b/cmd/podman/pull.go index 7cc7b65b3..04eb5bd46 100644 --- a/cmd/podman/pull.go +++ b/cmd/podman/pull.go @@ -32,6 +32,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { pullCommand.InputArgs = args pullCommand.GlobalFlags = MainGlobalOpts + pullCommand.Remote = remoteclient return pullCmd(&pullCommand) }, Example: `podman pull imageName @@ -117,7 +118,7 @@ func pullCmd(c *cliconfig.PullValues) (retError error) { DockerRegistryCreds: registryCreds, DockerCertPath: c.CertDir, } - if c.Flag("tls-verify").Changed { + if c.IsSet("tls-verify") { dockerRegistryOptions.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!c.TlsVerify) } diff --git a/cmd/podman/push.go b/cmd/podman/push.go index a5638a698..e6beaaeb4 100644 --- a/cmd/podman/push.go +++ b/cmd/podman/push.go @@ -31,6 +31,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { pushCommand.InputArgs = args pushCommand.GlobalFlags = MainGlobalOpts + pushCommand.Remote = remoteclient return pushCmd(&pushCommand) }, Example: `podman push imageID docker://registry.example.com/repository:tag diff --git a/cmd/podman/refresh.go b/cmd/podman/refresh.go index ed2e173ab..6640d9954 100644 --- a/cmd/podman/refresh.go +++ b/cmd/podman/refresh.go @@ -24,6 +24,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { refreshCommand.InputArgs = args refreshCommand.GlobalFlags = MainGlobalOpts + refreshCommand.Remote = remoteclient return refreshCmd(&refreshCommand) }, } diff --git a/cmd/podman/restart.go b/cmd/podman/restart.go index 1553ab805..5a9f3043a 100644 --- a/cmd/podman/restart.go +++ b/cmd/podman/restart.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { restartCommand.InputArgs = args restartCommand.GlobalFlags = MainGlobalOpts + restartCommand.Remote = remoteclient return restartCmd(&restartCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/restore.go b/cmd/podman/restore.go index 0f0150644..d9e85c267 100644 --- a/cmd/podman/restore.go +++ b/cmd/podman/restore.go @@ -23,6 +23,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { restoreCommand.InputArgs = args restoreCommand.GlobalFlags = MainGlobalOpts + restoreCommand.Remote = remoteclient return restoreCmd(&restoreCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go index 66f70a36f..e3ee186ce 100644 --- a/cmd/podman/rm.go +++ b/cmd/podman/rm.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { rmCommand.InputArgs = args rmCommand.GlobalFlags = MainGlobalOpts + rmCommand.Remote = remoteclient return rmCmd(&rmCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/rmi.go b/cmd/podman/rmi.go index 149cd8d82..7ec875d5b 100644 --- a/cmd/podman/rmi.go +++ b/cmd/podman/rmi.go @@ -21,6 +21,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { rmiCommand.InputArgs = args rmiCommand.GlobalFlags = MainGlobalOpts + rmiCommand.Remote = remoteclient return rmiCmd(&rmiCommand) }, Example: `podman rmi imageID diff --git a/cmd/podman/run.go b/cmd/podman/run.go index d3158de6b..717a36e04 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -19,6 +19,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { runCommand.InputArgs = args runCommand.GlobalFlags = MainGlobalOpts + runCommand.Remote = remoteclient return runCmd(&runCommand) }, Example: `podman run imageID ls -alF /etc diff --git a/cmd/podman/runlabel.go b/cmd/podman/runlabel.go index f79aa8b0e..8267e941f 100644 --- a/cmd/podman/runlabel.go +++ b/cmd/podman/runlabel.go @@ -30,6 +30,7 @@ Executes a command as described by a container image label. RunE: func(cmd *cobra.Command, args []string) error { runlabelCommand.InputArgs = args runlabelCommand.GlobalFlags = MainGlobalOpts + runlabelCommand.Remote = remoteclient return runlabelCmd(&runlabelCommand) }, Example: `podman container runlabel run imageID diff --git a/cmd/podman/save.go b/cmd/podman/save.go index c10679740..a45223b6a 100644 --- a/cmd/podman/save.go +++ b/cmd/podman/save.go @@ -33,6 +33,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { saveCommand.InputArgs = args saveCommand.GlobalFlags = MainGlobalOpts + saveCommand.Remote = remoteclient return saveCmd(&saveCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/search.go b/cmd/podman/search.go index e614887fc..13948aef0 100644 --- a/cmd/podman/search.go +++ b/cmd/podman/search.go @@ -29,6 +29,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { searchCommand.InputArgs = args searchCommand.GlobalFlags = MainGlobalOpts + searchCommand.Remote = remoteclient return searchCmd(&searchCommand) }, Example: `podman search --filter=is-official --limit 3 alpine diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index d694027db..3f54e193f 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -19,7 +19,6 @@ import ( ann "github.com/containers/libpod/pkg/annotations" "github.com/containers/libpod/pkg/inspect" ns "github.com/containers/libpod/pkg/namespaces" - "github.com/containers/libpod/pkg/rootless" cc "github.com/containers/libpod/pkg/spec" "github.com/containers/libpod/pkg/util" "github.com/docker/docker/pkg/signal" @@ -392,16 +391,6 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. } if c.IsSet("pod") { if strings.HasPrefix(originalPodName, "new:") { - if rootless.IsRootless() { - // To create a new pod, we must immediately create the userns. - became, ret, err := rootless.BecomeRootInUserNS() - if err != nil { - return nil, err - } - if became { - os.Exit(ret) - } - } // pod does not exist; lets make it var podOptions []libpod.PodCreateOption podOptions = append(podOptions, libpod.WithPodName(podName), libpod.WithInfraContainer(), libpod.WithPodCgroups()) @@ -489,17 +478,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. } // ENVIRONMENT VARIABLES - env := defaultEnvVariables - if data != nil { - for _, e := range data.Config.Env { - split := strings.SplitN(e, "=", 2) - if len(split) > 1 { - env[split[0]] = split[1] - } else { - env[split[0]] = "" - } - } - } + env := EnvVariablesFromData(data) if err := parse.ReadKVStrings(env, c.StringSlice("env-file"), c.StringArray("env")); err != nil { return nil, errors.Wrapf(err, "unable to process environment variables") } @@ -781,6 +760,23 @@ var defaultEnvVariables = map[string]string{ "TERM": "xterm", } +// EnvVariablesFromData gets sets the default environment variables +// for containers, and reads the variables from the image data, if present. +func EnvVariablesFromData(data *inspect.ImageData) map[string]string { + env := defaultEnvVariables + if data != nil { + for _, e := range data.Config.Env { + split := strings.SplitN(e, "=", 2) + if len(split) > 1 { + env[split[0]] = split[1] + } else { + env[split[0]] = "" + } + } + } + return env +} + func makeHealthCheckFromCli(c *GenericCLIResults) (*manifest.Schema2HealthConfig, error) { inCommand := c.String("healthcheck-command") inInterval := c.String("healthcheck-interval") diff --git a/cmd/podman/sign.go b/cmd/podman/sign.go index 75d723514..b19b6a840 100644 --- a/cmd/podman/sign.go +++ b/cmd/podman/sign.go @@ -30,6 +30,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { signCommand.InputArgs = args signCommand.GlobalFlags = MainGlobalOpts + signCommand.Remote = remoteclient return signCmd(&signCommand) }, Example: `podman sign --sign-by mykey imageID diff --git a/cmd/podman/start.go b/cmd/podman/start.go index 7d97319dd..ec05ce90e 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -25,6 +25,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { startCommand.InputArgs = args startCommand.GlobalFlags = MainGlobalOpts + startCommand.Remote = remoteclient return startCmd(&startCommand) }, Example: `podman start --latest diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go index d379dbad7..6aa0cc10c 100644 --- a/cmd/podman/stats.go +++ b/cmd/podman/stats.go @@ -39,6 +39,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { statsCommand.InputArgs = args statsCommand.GlobalFlags = MainGlobalOpts + statsCommand.Remote = remoteclient return statsCmd(&statsCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go index 38d90fe81..f263bb166 100644 --- a/cmd/podman/stop.go +++ b/cmd/podman/stop.go @@ -21,6 +21,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { stopCommand.InputArgs = args stopCommand.GlobalFlags = MainGlobalOpts + stopCommand.Remote = remoteclient return stopCmd(&stopCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/system_df.go b/cmd/podman/system_df.go index 992e869bd..16a8ad120 100644 --- a/cmd/podman/system_df.go +++ b/cmd/podman/system_df.go @@ -33,6 +33,7 @@ var ( Long: dfSystemDescription, RunE: func(cmd *cobra.Command, args []string) error { dfSystemCommand.GlobalFlags = MainGlobalOpts + dfSystemCommand.Remote = remoteclient return dfSystemCmd(&dfSystemCommand) }, } diff --git a/cmd/podman/system_prune.go b/cmd/podman/system_prune.go index 624f24acb..436d54823 100644 --- a/cmd/podman/system_prune.go +++ b/cmd/podman/system_prune.go @@ -29,6 +29,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { pruneSystemCommand.InputArgs = args pruneSystemCommand.GlobalFlags = MainGlobalOpts + pruneSystemCommand.Remote = remoteclient return pruneSystemCmd(&pruneSystemCommand) }, } diff --git a/cmd/podman/system_renumber.go b/cmd/podman/system_renumber.go index ed0b28a3c..70ba706bb 100644 --- a/cmd/podman/system_renumber.go +++ b/cmd/podman/system_renumber.go @@ -24,6 +24,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { renumberCommand.InputArgs = args renumberCommand.GlobalFlags = MainGlobalOpts + renumberCommand.Remote = remoteclient return renumberCmd(&renumberCommand) }, } diff --git a/cmd/podman/tag.go b/cmd/podman/tag.go index 98d9a6856..deda4e985 100644 --- a/cmd/podman/tag.go +++ b/cmd/podman/tag.go @@ -18,6 +18,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { tagCommand.InputArgs = args tagCommand.GlobalFlags = MainGlobalOpts + tagCommand.Remote = remoteclient return tagCmd(&tagCommand) }, Example: `podman tag 0e3bbc2 fedora:latest diff --git a/cmd/podman/top.go b/cmd/podman/top.go index 5d394d2d6..0b7da64a8 100644 --- a/cmd/podman/top.go +++ b/cmd/podman/top.go @@ -39,6 +39,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { topCommand.InputArgs = args topCommand.GlobalFlags = MainGlobalOpts + topCommand.Remote = remoteclient return topCmd(&topCommand) }, Example: `podman top ctrID diff --git a/cmd/podman/tree.go b/cmd/podman/tree.go index 371e88495..f205c83e4 100644 --- a/cmd/podman/tree.go +++ b/cmd/podman/tree.go @@ -29,6 +29,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { treeCommand.InputArgs = args treeCommand.GlobalFlags = MainGlobalOpts + treeCommand.Remote = remoteclient return treeCmd(&treeCommand) }, Example: "podman image tree alpine:latest", diff --git a/cmd/podman/trust_set_show.go b/cmd/podman/trust_set_show.go index 626d27aae..580331673 100644 --- a/cmd/podman/trust_set_show.go +++ b/cmd/podman/trust_set_show.go @@ -29,6 +29,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { setTrustCommand.InputArgs = args setTrustCommand.GlobalFlags = MainGlobalOpts + setTrustCommand.Remote = remoteclient return setTrustCmd(&setTrustCommand) }, } diff --git a/cmd/podman/umount.go b/cmd/podman/umount.go index 914e37cfa..cdf8b951a 100644 --- a/cmd/podman/umount.go +++ b/cmd/podman/umount.go @@ -24,6 +24,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { umountCommand.InputArgs = args umountCommand.GlobalFlags = MainGlobalOpts + umountCommand.Remote = remoteclient return umountCmd(&umountCommand) }, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/podman/unpause.go b/cmd/podman/unpause.go index 0c52a2443..65e841b36 100644 --- a/cmd/podman/unpause.go +++ b/cmd/podman/unpause.go @@ -23,6 +23,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { unpauseCommand.InputArgs = args unpauseCommand.GlobalFlags = MainGlobalOpts + unpauseCommand.Remote = remoteclient return unpauseCmd(&unpauseCommand) }, Example: `podman unpause ctrID diff --git a/cmd/podman/utils.go b/cmd/podman/utils.go index 81bd02faa..986db469e 100644 --- a/cmd/podman/utils.go +++ b/cmd/podman/utils.go @@ -51,29 +51,3 @@ func markFlagHiddenForRemoteClient(flagName string, flags *pflag.FlagSet) { flags.MarkHidden(flagName) } } - -// TODO: remove when adapter package takes over this functionality -// func joinContainerOrCreateRootlessUserNS(runtime *libpod.Runtime, ctr *libpod.Container) (bool, int, error) { -// if os.Geteuid() == 0 { -// return false, 0, nil -// } -// s, err := ctr.State() -// if err != nil { -// return false, -1, err -// } -// opts := rootless.Opts{ -// Argument: ctr.ID(), -// } -// if s == libpod.ContainerStateRunning || s == libpod.ContainerStatePaused { -// data, err := ioutil.ReadFile(ctr.Config().ConmonPidFile) -// if err != nil { -// return false, -1, errors.Wrapf(err, "cannot read conmon PID file %q", ctr.Config().ConmonPidFile) -// } -// conmonPid, err := strconv.Atoi(string(data)) -// if err != nil { -// return false, -1, errors.Wrapf(err, "cannot parse PID %q", data) -// } -// return rootless.JoinDirectUserAndMountNSWithOpts(uint(conmonPid), &opts) -// } -// return rootless.BecomeRootInUserNSWithOpts(&opts) -// } diff --git a/cmd/podman/version.go b/cmd/podman/version.go index 31b0b8e82..e964bdbb5 100644 --- a/cmd/podman/version.go +++ b/cmd/podman/version.go @@ -23,6 +23,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { versionCommand.InputArgs = args versionCommand.GlobalFlags = MainGlobalOpts + versionCommand.Remote = remoteclient return versionCmd(&versionCommand) }, } diff --git a/cmd/podman/volume_create.go b/cmd/podman/volume_create.go index 8f6237272..2b10adb2b 100644 --- a/cmd/podman/volume_create.go +++ b/cmd/podman/volume_create.go @@ -21,6 +21,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { volumeCreateCommand.InputArgs = args volumeCreateCommand.GlobalFlags = MainGlobalOpts + volumeCreateCommand.Remote = remoteclient return volumeCreateCmd(&volumeCreateCommand) }, Example: `podman volume create myvol diff --git a/cmd/podman/volume_inspect.go b/cmd/podman/volume_inspect.go index fdd8b5b0b..66d394307 100644 --- a/cmd/podman/volume_inspect.go +++ b/cmd/podman/volume_inspect.go @@ -19,6 +19,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { volumeInspectCommand.InputArgs = args volumeInspectCommand.GlobalFlags = MainGlobalOpts + volumeInspectCommand.Remote = remoteclient return volumeInspectCmd(&volumeInspectCommand) }, Example: `podman volume inspect myvol diff --git a/cmd/podman/volume_ls.go b/cmd/podman/volume_ls.go index 2f35462a3..b9ab89196 100644 --- a/cmd/podman/volume_ls.go +++ b/cmd/podman/volume_ls.go @@ -54,6 +54,7 @@ and the output format can be changed to JSON or a user specified Go template.` RunE: func(cmd *cobra.Command, args []string) error { volumeLsCommand.InputArgs = args volumeLsCommand.GlobalFlags = MainGlobalOpts + volumeLsCommand.Remote = remoteclient return volumeLsCmd(&volumeLsCommand) }, } diff --git a/cmd/podman/volume_prune.go b/cmd/podman/volume_prune.go index 70ba506e7..ad62bfc22 100644 --- a/cmd/podman/volume_prune.go +++ b/cmd/podman/volume_prune.go @@ -28,6 +28,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { volumePruneCommand.InputArgs = args volumePruneCommand.GlobalFlags = MainGlobalOpts + volumePruneCommand.Remote = remoteclient return volumePruneCmd(&volumePruneCommand) }, } diff --git a/cmd/podman/volume_rm.go b/cmd/podman/volume_rm.go index 8c6d5e97a..4534019c6 100644 --- a/cmd/podman/volume_rm.go +++ b/cmd/podman/volume_rm.go @@ -22,6 +22,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { volumeRmCommand.InputArgs = args volumeRmCommand.GlobalFlags = MainGlobalOpts + volumeRmCommand.Remote = remoteclient return volumeRmCmd(&volumeRmCommand) }, Example: `podman volume rm myvol1 myvol2 diff --git a/cmd/podman/wait.go b/cmd/podman/wait.go index 827ac6826..97ec75b0c 100644 --- a/cmd/podman/wait.go +++ b/cmd/podman/wait.go @@ -21,6 +21,7 @@ var ( RunE: func(cmd *cobra.Command, args []string) error { waitCommand.InputArgs = args waitCommand.GlobalFlags = MainGlobalOpts + waitCommand.Remote = remoteclient return waitCmd(&waitCommand) }, Example: `podman wait --latest diff --git a/docs/podman-export.1.md b/docs/podman-export.1.md index d0e365056..5928a8080 100644 --- a/docs/podman-export.1.md +++ b/docs/podman-export.1.md @@ -37,7 +37,7 @@ $ podman export > redis-container.tar 883504668ec465463bc0fe7e63d53154ac3b696ea8 ``` ## SEE ALSO -podman(1), podman-import(1), crio(8) +podman(1), podman-import(1) ## HISTORY August 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-history.1.md b/docs/podman-history.1.md index 8335428a8..b8f86026b 100644 --- a/docs/podman-history.1.md +++ b/docs/podman-history.1.md @@ -90,7 +90,7 @@ $ podman history --format json debian ``` ## SEE ALSO -podman(1), crio(8) +podman(1) ## HISTORY July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-image-tree.1.md b/docs/podman-image-tree.1.md index acd5ffcbf..3920aabde 100644 --- a/docs/podman-image-tree.1.md +++ b/docs/podman-image-tree.1.md @@ -82,7 +82,7 @@ Image Layers ## SEE ALSO -podman(1), crio(8) +podman(1) ## HISTORY Feb 2019, Originally compiled by Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp> diff --git a/docs/podman-import.1.md b/docs/podman-import.1.md index 03055018a..d9720f81d 100644 --- a/docs/podman-import.1.md +++ b/docs/podman-import.1.md @@ -83,7 +83,7 @@ db65d991f3bbf7f31ed1064db9a6ced7652e3f8166c4736aa9133dadd3c7acb3 ``` ## SEE ALSO -podman(1), podman-export(1), crio(8) +podman(1), podman-export(1) ## HISTORY November 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-info.1.md b/docs/podman-info.1.md index a6579ec1f..c606a4422 100644 --- a/docs/podman-info.1.md +++ b/docs/podman-info.1.md @@ -148,4 +148,4 @@ map[registries:[docker.io quay.io registry.fedoraproject.org registry.access.red ``` ## SEE ALSO -podman(1), containers-registries.conf(5), containers-storage.conf(5), crio(8) +podman(1), containers-registries.conf(5), containers-storage.conf(5) diff --git a/docs/podman-load.1.md b/docs/podman-load.1.md index 8a1660c63..d156a7682 100644 --- a/docs/podman-load.1.md +++ b/docs/podman-load.1.md @@ -77,7 +77,7 @@ Loaded image: registry.fedoraproject.org/fedora:latest ``` ## SEE ALSO -podman(1), podman-save(1), podman-tag(1), crio(8) +podman(1), podman-save(1), podman-tag(1) ## HISTORY July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-login.1.md b/docs/podman-login.1.md index 3ac0e30ef..a3fcd1eea 100644 --- a/docs/podman-login.1.md +++ b/docs/podman-login.1.md @@ -101,7 +101,7 @@ Login Succeeded! ``` ## SEE ALSO -podman(1), podman-logout(1), crio(8) +podman(1), podman-logout(1) ## HISTORY August 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-logout.1.md b/docs/podman-logout.1.md index be0c52e39..b848fcdee 100644 --- a/docs/podman-logout.1.md +++ b/docs/podman-logout.1.md @@ -53,7 +53,7 @@ Remove login credentials for all registries ``` ## SEE ALSO -podman(1), podman-login(1), crio(8) +podman(1), podman-login(1) ## HISTORY August 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-ps.1.md b/docs/podman-ps.1.md index f2b77e983..8d35c8254 100644 --- a/docs/podman-ps.1.md +++ b/docs/podman-ps.1.md @@ -166,7 +166,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS Print a list of containers ## SEE ALSO -podman(1), crio(8) +podman(1) ## HISTORY August 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-pull.1.md b/docs/podman-pull.1.md index bce11b096..92740c3af 100644 --- a/docs/podman-pull.1.md +++ b/docs/podman-pull.1.md @@ -146,7 +146,7 @@ Storing signatures registries.conf is the configuration file which specifies which container registries should be consulted when completing image names which do not include a registry or domain portion. ## SEE ALSO -podman(1), podman-push(1), podman-login(1), containers-registries.conf(5), crio(8) +podman(1), podman-push(1), podman-login(1), containers-registries.conf(5) ## HISTORY July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-push.1.md b/docs/podman-push.1.md index bb17c7e03..73fdd625e 100644 --- a/docs/podman-push.1.md +++ b/docs/podman-push.1.md @@ -144,4 +144,4 @@ Storing signatures ``` ## SEE ALSO -podman(1), podman-pull(1), podman-login(1), crio(8) +podman(1), podman-pull(1), podman-login(1) diff --git a/docs/podman-save.1.md b/docs/podman-save.1.md index 75aeda797..8e01c230d 100644 --- a/docs/podman-save.1.md +++ b/docs/podman-save.1.md @@ -91,7 +91,7 @@ Storing signatures ``` ## SEE ALSO -podman(1), podman-load(1), crio(8) +podman(1), podman-load(1) ## HISTORY July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-search.1.md b/docs/podman-search.1.md index 61f50f1dc..312cdae59 100644 --- a/docs/podman-search.1.md +++ b/docs/podman-search.1.md @@ -149,7 +149,7 @@ Note: This works only with registries that implement the v2 API. If tried with a registries.conf is the configuration file which specifies which container registries should be consulted when completing image names which do not include a registry or domain portion. ## SEE ALSO -podman(1), containers-registries.conf(5), crio(8) +podman(1), containers-registries.conf(5) ## HISTORY January 2018, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/podman-tag.1.md b/docs/podman-tag.1.md index 6525995f0..05bcc5fbc 100644 --- a/docs/podman-tag.1.md +++ b/docs/podman-tag.1.md @@ -28,7 +28,7 @@ $ podman tag httpd myregistryhost:5000/fedora/httpd:v2 ## SEE ALSO -podman(1), crio(8) +podman(1) ## HISTORY July 2017, Originally compiled by Ryan Cole <rycole@redhat.com> diff --git a/docs/podman-version.1.md b/docs/podman-version.1.md index 171096587..97977d94b 100644 --- a/docs/podman-version.1.md +++ b/docs/podman-version.1.md @@ -39,7 +39,7 @@ $ podman version --format '{{.Version}}' ``` ## SEE ALSO -podman(1), crio(8) +podman(1) ## HISTORY November 2018, Added --format flag by Tomas Tomecek <ttomecek@redhat.com> diff --git a/docs/podman-wait.1.md b/docs/podman-wait.1.md index ed5e11ac7..9ae4f668e 100644 --- a/docs/podman-wait.1.md +++ b/docs/podman-wait.1.md @@ -40,7 +40,7 @@ $ podman wait mywebserver myftpserver ``` ## SEE ALSO -podman(1), crio(8) +podman(1) ## HISTORY September 2017, Originally compiled by Brent Baude<bbaude@redhat.com> diff --git a/docs/podman.1.md b/docs/podman.1.md index 11dd50cb6..9c0ca8a7a 100644 --- a/docs/podman.1.md +++ b/docs/podman.1.md @@ -237,7 +237,7 @@ Images are pulled under `XDG_DATA_HOME` when specified, otherwise in the home di Currently the slirp4netns package is required to be installed to create a network device, otherwise rootless containers need to run in the network namespace of the host. ## SEE ALSO -`containers-mounts.conf(5)`, `containers-registries.conf(5)`, `containers-storage.conf(5)`, `buildah(1)`, `crio(8)`, `libpod.conf(5)`, `oci-hooks(5)`, `policy.json(5)`, `subuid(5)`, `subgid(5)`, `slirp4netns(1)` +`containers-mounts.conf(5)`, `containers-registries.conf(5)`, `containers-storage.conf(5)`, `buildah(1)`, `libpod.conf(5)`, `oci-hooks(5)`, `policy.json(5)`, `subuid(5)`, `subgid(5)`, `slirp4netns(1)` ## HISTORY Dec 2016, Originally compiled by Dan Walsh <dwalsh@redhat.com> diff --git a/libpod/container_commit.go b/libpod/container_commit.go index db67f7a30..3cc4b2c92 100644 --- a/libpod/container_commit.go +++ b/libpod/container_commit.go @@ -3,6 +3,7 @@ package libpod import ( "context" "fmt" + "os" "strings" "github.com/containers/buildah" @@ -126,18 +127,40 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai // Process user changes for _, change := range options.Changes { - splitChange := strings.Split(change, "=") + splitChange := strings.SplitN(change, " ", 2) + if len(splitChange) != 2 { + splitChange = strings.SplitN(change, "=", 2) + if len(splitChange) < 2 { + return nil, errors.Errorf("invalid change %s format", change) + } + } + + change := strings.Split(splitChange[1], " ") switch strings.ToUpper(splitChange[0]) { case "CMD": - importBuilder.SetCmd(splitChange[1:]) + importBuilder.SetCmd(change) case "ENTRYPOINT": - importBuilder.SetEntrypoint(splitChange[1:]) + importBuilder.SetEntrypoint(change) case "ENV": + name := change[0] + val := "" + if len(change) < 2 { + change = strings.Split(change[0], "=") + } + if len(change) < 2 { + var ok bool + val, ok = os.LookupEnv(name) + if !ok { + return nil, errors.Errorf("invalid env variable %q: not defined in your environment", name) + } + } else { + val = strings.Join(change[1:], " ") + } if !isEnvCleared { // Multiple values are valid, only clear once. importBuilder.ClearEnv() isEnvCleared = true } - importBuilder.SetEnv(splitChange[1], splitChange[2]) + importBuilder.SetEnv(name, val) case "EXPOSE": if !isExposeCleared { // Multiple values are valid, only clear once importBuilder.ClearPorts() @@ -145,11 +168,17 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai } importBuilder.SetPort(splitChange[1]) case "LABEL": + if len(change) < 2 { + change = strings.Split(change[0], "=") + } + if len(change) < 2 { + return nil, errors.Errorf("invalid label %s format, requires to NAME=VAL", splitChange[1]) + } if !isLabelCleared { // multiple values are valid, only clear once importBuilder.ClearLabels() isLabelCleared = true } - importBuilder.SetLabel(splitChange[1], splitChange[2]) + importBuilder.SetLabel(change[0], strings.Join(change[1:], " ")) case "ONBUILD": importBuilder.SetOnBuild(splitChange[1]) case "STOPSIGNAL": diff --git a/pkg/adapter/runtime.go b/pkg/adapter/runtime.go index 6aafed550..b5ec9f7a9 100644 --- a/pkg/adapter/runtime.go +++ b/pkg/adapter/runtime.go @@ -311,46 +311,6 @@ func (r *LocalRuntime) HealthCheck(c *cliconfig.HealthCheckValues) (libpod.Healt return r.Runtime.HealthCheck(c.InputArgs[0]) } -// JoinOrCreateRootlessPod joins the specified pod if it is running or it creates a new user namespace -// if the pod is stopped -// func (r *LocalRuntime) JoinOrCreateRootlessPod(pod *Pod) (bool, int, error) { -// if os.Geteuid() == 0 { -// return false, 0, nil -// } -// opts := rootless.Opts{ -// Argument: pod.ID(), -// } -// -// inspect, err := pod.Inspect() -// if err != nil { -// return false, 0, err -// } -// for _, ctr := range inspect.Containers { -// prevCtr, err := r.LookupContainer(ctr.ID) -// if err != nil { -// return false, -1, err -// } -// s, err := prevCtr.State() -// if err != nil { -// return false, -1, err -// } -// if s != libpod.ContainerStateRunning && s != libpod.ContainerStatePaused { -// continue -// } -// data, err := ioutil.ReadFile(prevCtr.Config().ConmonPidFile) -// if err != nil { -// return false, -1, errors.Wrapf(err, "cannot read conmon PID file %q", prevCtr.Config().ConmonPidFile) -// } -// conmonPid, err := strconv.Atoi(string(data)) -// if err != nil { -// return false, -1, errors.Wrapf(err, "cannot parse PID %q", data) -// } -// return rootless.JoinDirectUserAndMountNSWithOpts(uint(conmonPid), &opts) -// } -// -// return rootless.BecomeRootInUserNSWithOpts(&opts) -// } - // Events is a wrapper to libpod to obtain libpod/podman events func (r *LocalRuntime) Events(c *cliconfig.EventValues) error { var ( |