diff options
-rw-r--r-- | cmd/podman/shared/create.go | 2 | ||||
-rw-r--r-- | cmd/podman/shared/parse/parse.go | 5 | ||||
-rw-r--r-- | docs/podman-create.1.md | 17 | ||||
-rw-r--r-- | docs/podman-run.1.md | 15 | ||||
-rw-r--r-- | libpod.conf | 6 | ||||
-rw-r--r-- | libpod/runtime.go | 2 | ||||
-rw-r--r-- | test/e2e/run_test.go | 5 |
7 files changed, 44 insertions, 8 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 43b1b4067..4de68e4bc 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -80,6 +80,8 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod. name := "" if len(c.InputArgs) != 0 { name = c.InputArgs[0] + } else { + return nil, nil, errors.Errorf("error, no input arguments were provided") } newImage, err := runtime.ImageRuntime().New(ctx, name, rtc.SignaturePolicyPath, GetAuthFile(""), writer, nil, image.SigningOptions{}, false, nil) if err != nil { diff --git a/cmd/podman/shared/parse/parse.go b/cmd/podman/shared/parse/parse.go index 9fbc92fc3..3a75ff7a8 100644 --- a/cmd/podman/shared/parse/parse.go +++ b/cmd/podman/shared/parse/parse.go @@ -126,8 +126,9 @@ func parseEnv(env map[string]string, line string) error { } } else { // if only a pass-through variable is given, clean it up. - val, _ := os.LookupEnv(name) - env[name] = val + if val, ok := os.LookupEnv(name); ok { + env[name] = val + } } } return nil diff --git a/docs/podman-create.1.md b/docs/podman-create.1.md index d796c2586..50fca3541 100644 --- a/docs/podman-create.1.md +++ b/docs/podman-create.1.md @@ -253,9 +253,9 @@ You need to specify multi option commands in the form of a json string. Set environment variables -This option allows you to specify arbitrary environment variables that are available for the process that will be launched inside of the container. If you specify a environment variable without a value, podman will check the host environment for a value or set the environment to "". If you specify a environment variable ending in --*--, podman will search the host environment for variables starting with the prefix and add them to the container. If you want to add an environment variable with a ***** following it, then you need to set a value. +This option allows arbitrary environment variables that are available for the process to be launched inside of the container. If an environment variable is specified without a value, Podman will check the host environment for a value and set the variable only if it is set on the host. If an environment variable ending in __*__ is specified, Podman will search the host environment for variables starting with the prefix and will add those variables to the container. If an environment variable with a trailing ***** is specified, then a value must be supplied. -See **Environment** note below for precedence. +See [**Environment**](#environment) note below for precedence and examples. **--env-host**=*true|false* @@ -933,6 +933,19 @@ Precedence Order: **--env** : Any environment variables specified will override previous settings. +Create containers and set the environment ending with a __*__ and a ***** + +``` +$ export ENV1=a +$ podman create --name ctr --env ENV* alpine printenv ENV1 +$ podman start --attach ctr +a + +$ podman create --name ctr --env ENV*****=b alpine printenv ENV***** +$ podman start --attach ctr +b +``` + ## FILES **/etc/subuid** diff --git a/docs/podman-run.1.md b/docs/podman-run.1.md index f5f44fad4..209a07c0c 100644 --- a/docs/podman-run.1.md +++ b/docs/podman-run.1.md @@ -260,9 +260,9 @@ You need to specify multi option commands in the form of a json string. Set environment variables -This option allows you to specify arbitrary environment variables that are available for the process that will be launched inside of the container. If you specify a environment variable without a value, podman will check the host environment for a value or set the environment to "". If you specify a environment variable ending in --*--, podman will search the host environment for variables starting with the prefix and add them to the container. If you want to add an environment variable with a ***** following it, then you need to set a value. +This option allows arbitrary environment variables that are available for the process to be launched inside of the container. If an environment variable is specified without a value, Podman will check the host environment for a value and set the variable only if it is set on the host. If an environment variable ending in __*__ is specified, Podman will search the host environment for variables starting with the prefix and will add those variables to the container. If an environment variable with a trailing ***** is specified, then a value must be supplied. -See **Environment** note below for precedence. +See [**Environment**](#environment) note below for precedence and examples. **--env-host**=*true|false* @@ -1219,6 +1219,17 @@ Precedence Order: **--env** : Any environment variables specified will override previous settings. +Run containers and set the environment ending with a __*__ and a ***** + +``` +$ export ENV1=a +$ $ podman run --env ENV* alpine printenv ENV1 +a + +$ podman run --env ENV*****=b alpine printenv ENV***** +b +``` + ## FILES **/etc/subuid** diff --git a/libpod.conf b/libpod.conf index c92f60a10..6dd021c02 100644 --- a/libpod.conf +++ b/libpod.conf @@ -12,7 +12,8 @@ conmon_path = [ "/usr/bin/conmon", "/usr/sbin/conmon", "/usr/local/bin/conmon", - "/usr/local/sbin/conmon" + "/usr/local/sbin/conmon", + "/run/current-system/sw/bin/conmon", ] # Environment variables to pass into conmon @@ -128,7 +129,8 @@ runc = [ "/usr/local/sbin/runc", "/sbin/runc", "/bin/runc", - "/usr/lib/cri-o-runc/sbin/runc" + "/usr/lib/cri-o-runc/sbin/runc", + "/run/current-system/sw/bin/runc", ] crun = [ diff --git a/libpod/runtime.go b/libpod/runtime.go index 28958e932..bb6bfbfcc 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -293,6 +293,7 @@ func defaultRuntimeConfig() (RuntimeConfig, error) { "/sbin/runc", "/bin/runc", "/usr/lib/cri-o-runc/sbin/runc", + "/run/current-system/sw/bin/runc", }, }, ConmonPath: []string{ @@ -302,6 +303,7 @@ func defaultRuntimeConfig() (RuntimeConfig, error) { "/usr/sbin/conmon", "/usr/local/bin/conmon", "/usr/local/sbin/conmon", + "/run/current-system/sw/bin/conmon", }, ConmonEnvVars: []string{ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go index e35c84f5b..7b5ff2547 100644 --- a/test/e2e/run_test.go +++ b/test/e2e/run_test.go @@ -213,6 +213,11 @@ var _ = Describe("Podman run", func() { Expect(match).Should(BeTrue()) os.Unsetenv("FOO") + session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO", ALPINE, "printenv", "FOO"}) + session.WaitWithDefaultTimeout() + Expect(len(session.OutputToString())).To(Equal(0)) + Expect(session.ExitCode()).To(Equal(1)) + session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) |