Skip to content

Commit

Permalink
The compat create endpoint should 404 on no such image
Browse files Browse the repository at this point in the history
This matches Docker behavior, and will make the Docker frontend
work with `podman system service` (Docker tries to create, then
if that fails with 404 sends a request to pull the image).

Fixes containers#6960

Signed-off-by: Matthew Heon <[email protected]>
  • Loading branch information
mheon committed Jul 16, 2020
1 parent f4766e0 commit fc81d2a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/api/handlers/compat/containers_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/containers/common/pkg/config"
"github.com/containers/libpod/v2/libpod"
"github.com/containers/libpod/v2/libpod/define"
image2 "github.com/containers/libpod/v2/libpod/image"
"github.com/containers/libpod/v2/pkg/api/handlers"
"github.com/containers/libpod/v2/pkg/api/handlers/utils"
Expand Down Expand Up @@ -45,6 +46,11 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
}
newImage, err := runtime.ImageRuntime().NewFromLocal(input.Image)
if err != nil {
if errors.Cause(err) == define.ErrNoSuchImage {
utils.Error(w, "No such image", http.StatusNotFound, err)
return
}

utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "NewFromLocal()"))
return
}
Expand Down

0 comments on commit fc81d2a

Please sign in to comment.