diff --git a/oci/spec_opts.go b/oci/spec_opts.go index 8fe3247b5..4f81eaef2 100644 --- a/oci/spec_opts.go +++ b/oci/spec_opts.go @@ -326,7 +326,7 @@ func WithImageConfigArgs(image Image, args []string) SpecOpts { setProcess(s) if s.Linux != nil { - s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, config.Env) + s.Process.Env = replaceOrAppendEnvValues(config.Env, s.Process.Env) cmd := config.Cmd if len(args) > 0 { cmd = args @@ -348,7 +348,7 @@ func WithImageConfigArgs(image Image, args []string) SpecOpts { // even if there is no specified user in the image config return WithAdditionalGIDs("root")(ctx, client, c, s) } else if s.Windows != nil { - s.Process.Env = replaceOrAppendEnvValues(s.Process.Env, config.Env) + s.Process.Env = replaceOrAppendEnvValues(config.Env, s.Process.Env) cmd := config.Cmd if len(args) > 0 { cmd = args diff --git a/oci/spec_opts_test.go b/oci/spec_opts_test.go index b5193a832..77cbe2261 100644 --- a/oci/spec_opts_test.go +++ b/oci/spec_opts_test.go @@ -406,7 +406,7 @@ func TestWithImageConfigArgs(t *testing.T) { WithImageConfigArgs(img, []string{"--boo", "bar"}), } - expectedEnv := []string{"x=foo", "y=baz", "z=bar"} + expectedEnv := []string{"z=bar", "y=boo", "x=foo"} expectedArgs := []string{"create", "--namespace=test", "--boo", "bar"} for _, opt := range opts {