mirror of
https://github.com/containers/podman.git
synced 2025-10-18 11:42:55 +08:00
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 <jkaluza@redhat.com> (cherry picked from commit 3a981915f006b166df7d4207eb154c893af99dce) Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:

committed by
Paul Holzinger

parent
d71fbe7ba8
commit
ee2370bc26
@ -207,6 +207,12 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
|
|||||||
jsonString := string(b)
|
jsonString := string(b)
|
||||||
entrypoint = &jsonString
|
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
|
// expose ports
|
||||||
|
@ -782,6 +782,26 @@ if root && test -e /dev/nullb0; then
|
|||||||
podman rm -f updateCtr
|
podman rm -f updateCtr
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# test apiv2 create container with empty entrypoint
|
||||||
|
# --data '{"Image":"quay.io/libpod/some:thing","Entrypoint": []}'
|
||||||
|
# Fixes #26078
|
||||||
|
podman image build -t test1:latest -<<EOF
|
||||||
|
from alpine
|
||||||
|
ENTRYPOINT ["echo", "test"]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
t POST containers/create \
|
||||||
|
Image=test1:latest \
|
||||||
|
Entrypoint=[] \
|
||||||
|
201 \
|
||||||
|
.Id~[0-9a-f]\\{64\\}
|
||||||
|
cid=$(jq -r '.Id' <<<"$output")
|
||||||
|
t GET containers/$cid/json 200 \
|
||||||
|
.Config.Entrypoint[0]=null
|
||||||
|
|
||||||
|
t DELETE containers/$cid 204
|
||||||
|
podman rmi test1
|
||||||
|
|
||||||
|
|
||||||
# test if API support -1 for ulimits https://github.com/containers/podman/issues/24886
|
# test if API support -1 for ulimits https://github.com/containers/podman/issues/24886
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ function jsonify() {
|
|||||||
local rhs
|
local rhs
|
||||||
IFS='=' read lhs rhs <<<"$i"
|
IFS='=' read lhs rhs <<<"$i"
|
||||||
|
|
||||||
if [[ $rhs =~ \" || $rhs == true || $rhs == false || $rhs =~ ^-?[0-9]+$ ]]; then
|
if [[ $rhs =~ \" || $rhs == true || $rhs == false || $rhs == "[]" || $rhs =~ ^-?[0-9]+$ ]]; then
|
||||||
# rhs has been pre-formatted for JSON or a non-string, do not change it
|
# rhs has been pre-formatted for JSON or a non-string, do not change it
|
||||||
:
|
:
|
||||||
elif [[ $rhs == False ]]; then
|
elif [[ $rhs == False ]]; then
|
||||||
|
Reference in New Issue
Block a user