diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2017-11-07 10:03:46 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-11-20 16:25:31 +0000 |
commit | 57599f0075ccab859d4158f7ee891b9b971c731f (patch) | |
tree | 84bb48fc3ef1321a29816710cbb1221cc598b745 /cmd/kpod/spec.go | |
parent | 3b72af614777b966671ad0eb0c5dbde0eeedcfa2 (diff) | |
download | podman-57599f0075ccab859d4158f7ee891b9b971c731f.tar.gz podman-57599f0075ccab859d4158f7ee891b9b971c731f.tar.bz2 podman-57599f0075ccab859d4158f7ee891b9b971c731f.zip |
Fix up handling of environment variables
The way docker works is if a user specifies a non `-e Name=Value`, IE
just a `-e Name`, then the environment variable Name from the clients
OS.ENV is used.
Also by default Docker containers run with the HOSTNAME environment set
to the HOSTNAME specified for the container.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #21
Approved by: baude
Diffstat (limited to 'cmd/kpod/spec.go')
-rw-r--r-- | cmd/kpod/spec.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cmd/kpod/spec.go b/cmd/kpod/spec.go index 611a3cc56..d31f9c8ed 100644 --- a/cmd/kpod/spec.go +++ b/cmd/kpod/spec.go @@ -52,6 +52,9 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) { } g.SetRootReadonly(config.readOnlyRootfs) g.SetHostname(config.hostname) + if config.hostname != "" { + g.AddProcessEnv("HOSTNAME", config.hostname) + } for _, sysctl := range config.sysctl { s := strings.SplitN(sysctl, "=", 2) @@ -124,6 +127,10 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) { g.AddTmpfsMount(spliti[0], options) } + for name, val := range config.env { + g.AddProcessEnv(name, val) + } + configSpec := g.Spec() if config.seccompProfilePath != "" && config.seccompProfilePath != "unconfined" { @@ -138,8 +145,6 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) { configSpec.Linux.Seccomp = &seccompConfig } - configSpec.Process.Env = config.env - // BIND MOUNTS configSpec.Mounts = append(configSpec.Mounts, config.GetVolumeMounts()...) |