diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-04-01 09:49:21 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2020-04-02 13:10:08 -0400 |
commit | 1f8569f7d768c411b5fed4446817c79b4b5337a0 (patch) | |
tree | ee743630732dcad0828ef4880c3c706e50d62c18 /cmd/podman | |
parent | c3c6a7c8236fb43c3bc7172257b7fb15921e1668 (diff) | |
download | podman-1f8569f7d768c411b5fed4446817c79b4b5337a0.tar.gz podman-1f8569f7d768c411b5fed4446817c79b4b5337a0.tar.bz2 podman-1f8569f7d768c411b5fed4446817c79b4b5337a0.zip |
Fix environment handling from containers.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/shared/create.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 5fa8d6c0b..68a36d967 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -538,14 +538,16 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. } } - // env overrides any previous variables - cmdlineEnv := c.StringSlice("env") - if len(cmdlineEnv) > 0 { - parsedEnv, err := envLib.ParseSlice(cmdlineEnv) - if err != nil { - return nil, err + if c.IsSet("env") { + // env overrides any previous variables + cmdlineEnv := c.StringSlice("env") + if len(cmdlineEnv) > 0 { + parsedEnv, err := envLib.ParseSlice(cmdlineEnv) + if err != nil { + return nil, err + } + env = envLib.Join(env, parsedEnv) } - env = envLib.Join(env, parsedEnv) } // LABEL VARIABLES @@ -636,10 +638,13 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. if err != nil { return nil, errors.Wrapf(err, "unable to translate --shm-size") } - // Verify the additional hosts are in correct format - for _, host := range c.StringSlice("add-host") { - if _, err := parse.ValidateExtraHost(host); err != nil { - return nil, err + + if c.IsSet("add-host") { + // Verify the additional hosts are in correct format + for _, host := range c.StringSlice("add-host") { + if _, err := parse.ValidateExtraHost(host); err != nil { + return nil, err + } } } |