diff options
author | zhangguanzhang <zhangguanzhang@qq.com> | 2020-08-22 18:15:53 +0800 |
---|---|---|
committer | zhangguanzhang <zhangguanzhang@qq.com> | 2020-08-24 23:07:30 +0800 |
commit | fa6ba6802618e3e23746c4b4707fb403a55514ae (patch) | |
tree | 807e78f11803170afec2b27963398218ce1df4d0 /pkg/api/handlers/compat/containers_create.go | |
parent | 4828455055010a1376f1e83832bfa34787f3a1e7 (diff) | |
download | podman-fa6ba6802618e3e23746c4b4707fb403a55514ae.tar.gz podman-fa6ba6802618e3e23746c4b4707fb403a55514ae.tar.bz2 podman-fa6ba6802618e3e23746c4b4707fb403a55514ae.zip |
fix apiv2 will create containers with incorrect commands
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
Diffstat (limited to 'pkg/api/handlers/compat/containers_create.go')
-rw-r--r-- | pkg/api/handlers/compat/containers_create.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index 8238d2d93..93e4fe540 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -87,20 +87,21 @@ func makeCreateConfig(ctx context.Context, containerConfig *config.Config, input workDir = input.WorkingDir } - if input.Entrypoint == nil { - entrypointSlice, err := newImage.Entrypoint(ctx) + // Only use image's Cmd when the user does not set the entrypoint + if input.Entrypoint == nil && len(input.Cmd) == 0 { + cmdSlice, err := newImage.Cmd(ctx) if err != nil { return createconfig.CreateConfig{}, err } - input.Entrypoint = entrypointSlice + input.Cmd = cmdSlice } - if len(input.Cmd) == 0 { - cmdSlice, err := newImage.Cmd(ctx) + if input.Entrypoint == nil { + entrypointSlice, err := newImage.Entrypoint(ctx) if err != nil { return createconfig.CreateConfig{}, err } - input.Cmd = cmdSlice + input.Entrypoint = entrypointSlice } stopTimeout := containerConfig.Engine.StopTimeout |