From 03aca5e82bd6eef9de9453b11d74c86ce14bd524 Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Tue, 14 Nov 2017 05:35:44 +0000 Subject: [PATCH] Fix data race. Signed-off-by: Lantao Liu --- pkg/server/container_create.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/server/container_create.go b/pkg/server/container_create.go index 4a0c9ccb7..37c198271 100644 --- a/pkg/server/container_create.go +++ b/pkg/server/container_create.go @@ -442,11 +442,12 @@ func setOCIProcessArgs(g *generate.Generator, config *runtime.ContainerConfig, i // The following logic is migrated from https://github.com/moby/moby/blob/master/daemon/commit.go // TODO(random-liu): Clearly define the commands overwrite behavior. if len(command) == 0 { + // Copy array to avoid data race. if len(args) == 0 { - args = imageConfig.Cmd + args = append([]string{}, imageConfig.Cmd...) } if command == nil { - command = imageConfig.Entrypoint + command = append([]string{}, imageConfig.Entrypoint...) } } if len(command) == 0 && len(args) == 0 {