Skip to content

Commit

Permalink
Docker compat API - containers create ignores the name
Browse files Browse the repository at this point in the history
/containers/create compat endpoint does not set the name correctly (containers#7857)

Signed-off-by: Milivoje Legenovic <[email protected]>
  • Loading branch information
mlegenovic authored and mheon committed Dec 7, 2020
1 parent 4fa94d7 commit 9b4266e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/api/handlers/compat/containers_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/apiv2/rest_api/test_rest_v2_0_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9b4266e

Please sign in to comment.