From ee2370bc268367142a067009b3bf1119b6823c13 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Thu, 29 May 2025 08:40:28 +0200 Subject: [PATCH] Handle "Entrypoint":[] in compat containers/create API. When using `docker compose run --entrypoint ''`, docker sends `"Entrypoint": []` in the JSON. Podman currently treats that as `nil` and fallback to default image entrypoint. This is not what is expected by the user. Instead, it should not use any entrypoint. This commit fixes it by properly propagating the `[]` downstream to libpod. Fixes: #26078 Signed-off-by: Jan Kaluza (cherry picked from commit 3a981915f006b166df7d4207eb154c893af99dce) Signed-off-by: Paul Holzinger --- pkg/api/handlers/compat/containers_create.go | 6 ++++++ test/apiv2/20-containers.at | 20 ++++++++++++++++++++ test/apiv2/test-apiv2 | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index 77e469ddfb..5fe7c06a6d 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -207,6 +207,12 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C jsonString := string(b) entrypoint = &jsonString } + } else if cc.Config.Entrypoint != nil { + // Entrypoint in HTTP request is set, but it is an empty slice. + // Set the entrypoint to empty string slice, because keeping it set to nil + // would later fallback to default entrypoint. + emptySlice := "[]" + entrypoint = &emptySlice } // expose ports diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index 3dce2367b5..7ff2c2d7ea 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -782,6 +782,26 @@ if root && test -e /dev/nullb0; then podman rm -f updateCtr fi +# test apiv2 create container with empty entrypoint +# --data '{"Image":"quay.io/libpod/some:thing","Entrypoint": []}' +# Fixes #26078 +podman image build -t test1:latest -<