summaryrefslogtreecommitdiff
path: root/cmd/kpod/create.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-11-07 10:03:46 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-11-20 16:25:31 +0000
commit57599f0075ccab859d4158f7ee891b9b971c731f (patch)
tree84bb48fc3ef1321a29816710cbb1221cc598b745 /cmd/kpod/create.go
parent3b72af614777b966671ad0eb0c5dbde0eeedcfa2 (diff)
downloadpodman-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/create.go')
-rw-r--r--cmd/kpod/create.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/cmd/kpod/create.go b/cmd/kpod/create.go
index 0a0e31c40..73959ed02 100644
--- a/cmd/kpod/create.go
+++ b/cmd/kpod/create.go
@@ -27,7 +27,10 @@ const (
)
var (
- defaultEnvVariables = []string{"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "TERM=xterm"}
+ defaultEnvVariables = map[string]string{
+ "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
+ "TERM": "xterm",
+ }
)
type createResourceConfig struct {
@@ -64,16 +67,16 @@ type createConfig struct {
cidFile string
cgroupParent string // cgroup-parent
command []string
- detach bool // detach
- devices []*pb.Device // device
- dnsOpt []string //dns-opt
- dnsSearch []string //dns-search
- dnsServers []string //dns
- entrypoint string //entrypoint
- env []string //env
- expose []string //expose
- groupAdd []uint32 // group-add
- hostname string //hostname
+ detach bool // detach
+ devices []*pb.Device // device
+ dnsOpt []string //dns-opt
+ dnsSearch []string //dns-search
+ dnsServers []string //dns
+ entrypoint string //entrypoint
+ env map[string]string //env
+ expose []string //expose
+ groupAdd []uint32 // group-add
+ hostname string //hostname
image string
interactive bool //interactive
ip6Address string //ipv6
@@ -264,8 +267,8 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
return &createConfig{}, errors.Wrapf(err, "unable to process labels")
}
// ENVIRONMENT VARIABLES
- env, err := getAllEnvironmentVariables(c.StringSlice("env-file"), c.StringSlice("env"))
- if err != nil {
+ env := defaultEnvVariables
+ if err := readKVStrings(env, c.StringSlice("env-file"), c.StringSlice("env")); err != nil {
return &createConfig{}, errors.Wrapf(err, "unable to process environment variables")
}
@@ -338,7 +341,7 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
dnsServers: c.StringSlice("dns"),
entrypoint: c.String("entrypoint"),
env: env,
- expose: c.StringSlice("env"),
+ expose: c.StringSlice("expose"),
groupAdd: groupAdd,
hostname: c.String("hostname"),
image: image,