From 1f8569f7d768c411b5fed4446817c79b4b5337a0 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 1 Apr 2020 09:49:21 -0400 Subject: Fix environment handling from containers.conf Signed-off-by: Daniel J Walsh --- pkg/spec/spec.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'pkg/spec') diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index d4fd5976f..4732af757 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -316,7 +316,17 @@ func (config *CreateConfig) createConfigToOCISpec(runtime *libpod.Runtime, userM // Make sure to always set the default variables unless overridden in the // config. - config.Env = env.Join(env.DefaultEnvVariables, config.Env) + var defaultEnv map[string]string + if runtimeConfig == nil { + defaultEnv = env.DefaultEnvVariables + } else { + defaultEnv, err = env.ParseSlice(runtimeConfig.Containers.Env) + if err != nil { + return nil, errors.Wrap(err, "Env fields in containers.conf failed ot parse") + } + defaultEnv = env.Join(env.DefaultEnvVariables, defaultEnv) + } + config.Env = env.Join(defaultEnv, config.Env) for name, val := range config.Env { g.AddProcessEnv(name, val) } -- cgit v1.2.3-54-g00ecf