From f9bcbb7329a47f34261da2cfafa6bd5f63268437 Mon Sep 17 00:00:00 2001 From: Shengjing Zhu Date: Sat, 27 Feb 2021 01:48:13 +0800 Subject: [PATCH 1/2] cri: append envs from image config to empty slice to avoid env lost Signed-off-by: Yadong Zhang (cherry picked from commit https://github.com/containerd/containerd/commit/08318b1ab952e8c30908a9bd2855466d5bbe0ad9) Signed-off-by: Shengjing Zhu --- pkg/server/container_create_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/container_create_unix.go b/pkg/server/container_create_unix.go index 6ebebf9ad..bbe55e2cf 100644 --- a/pkg/server/container_create_unix.go +++ b/pkg/server/container_create_unix.go @@ -147,7 +147,7 @@ func (c *criService) containerSpec(id string, sandboxID string, sandboxPid uint3 // Apply envs from image config first, so that envs from container config // can override them. - env := imageConfig.Env + env := append([]string{}, imageConfig.Env...) for _, e := range config.GetEnvs() { env = append(env, e.GetKey()+"="+e.GetValue()) } From e4fcda3215cc607cc1f10657f76cbf85313fd64c Mon Sep 17 00:00:00 2001 From: Shengjing Zhu Date: Sat, 27 Feb 2021 01:49:43 +0800 Subject: [PATCH 2/2] cri: append envs from image config to empty slice to avoid env lost Signed-off-by: Justin Terry (SF) (cherry picked from commit https://github.com/containerd/containerd/commit/06e4e09567d8dda4b6e9543d4c80f3ffce1a206a) Signed-off-by: Shengjing Zhu --- pkg/server/container_create_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/container_create_windows.go b/pkg/server/container_create_windows.go index 86a08d89e..b689f3246 100644 --- a/pkg/server/container_create_windows.go +++ b/pkg/server/container_create_windows.go @@ -52,7 +52,7 @@ func (c *criService) containerSpec(id string, sandboxID string, sandboxPid uint3 // Apply envs from image config first, so that envs from container config // can override them. - env := imageConfig.Env + env := append([]string{}, imageConfig.Env...) for _, e := range config.GetEnvs() { env = append(env, e.GetKey()+"="+e.GetValue()) }