From 9b4266eb942b10926ea69ba13d84d5e36a61bd3c Mon Sep 17 00:00:00 2001 From: Milivoje Legenovic Date: Mon, 7 Dec 2020 12:50:10 +0100 Subject: [PATCH] Docker compat API - containers create ignores the name /containers/create compat endpoint does not set the name correctly (#7857) Signed-off-by: Milivoje Legenovic --- pkg/api/handlers/compat/containers_create.go | 6 +++--- test/apiv2/rest_api/test_rest_v2_0_0.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index 729639928e..409a74de22 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -37,6 +37,9 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { return } + // Override the container name in the body struct + body.Name = query.Name + if len(body.HostConfig.Links) > 0 { utils.Error(w, utils.ErrLinkNotSupport.Error(), http.StatusBadRequest, errors.Wrapf(utils.ErrLinkNotSupport, "bad parameter")) return @@ -69,9 +72,6 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { return } - // Override the container name in the body struct - body.Name = query.Name - ic := abi.ContainerEngine{Libpod: runtime} report, err := ic.ContainerCreate(r.Context(), sg) if err != nil { diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py index 52348d4f46..abb8200532 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -172,7 +172,7 @@ def test_post_create_compat_connect(self): self.assertEqual(net_default.status_code, 201, net_default.text) create = requests.post( - PODMAN_URL + "/v1.40/containers/create?name=postCreate", + PODMAN_URL + "/v1.40/containers/create?name=postCreateConnect", json={ "Cmd": ["top"], "Image": "alpine:latest",