aboutsummaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/containers_create.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/api/handlers/compat/containers_create.go')
-rw-r--r--pkg/api/handlers/compat/containers_create.go28
1 files changed, 17 insertions, 11 deletions
diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go
index cbee8a8b6..8238d2d93 100644
--- a/pkg/api/handlers/compat/containers_create.go
+++ b/pkg/api/handlers/compat/containers_create.go
@@ -8,13 +8,14 @@ import (
"strings"
"github.com/containers/common/pkg/config"
- "github.com/containers/libpod/v2/libpod"
- 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"
- "github.com/containers/libpod/v2/pkg/namespaces"
- "github.com/containers/libpod/v2/pkg/signal"
- createconfig "github.com/containers/libpod/v2/pkg/spec"
+ "github.com/containers/podman/v2/libpod"
+ "github.com/containers/podman/v2/libpod/define"
+ image2 "github.com/containers/podman/v2/libpod/image"
+ "github.com/containers/podman/v2/pkg/api/handlers"
+ "github.com/containers/podman/v2/pkg/api/handlers/utils"
+ "github.com/containers/podman/v2/pkg/namespaces"
+ "github.com/containers/podman/v2/pkg/signal"
+ createconfig "github.com/containers/podman/v2/pkg/spec"
"github.com/containers/storage"
"github.com/gorilla/schema"
"github.com/pkg/errors"
@@ -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
}
@@ -153,10 +159,10 @@ func makeCreateConfig(ctx context.Context, containerConfig *config.Config, input
User: input.User,
}
pidConfig := createconfig.PidConfig{PidMode: namespaces.PidMode(input.HostConfig.PidMode)}
- volumes := make([]string, 0, len(input.Volumes))
- for k := range input.Volumes {
- volumes = append(volumes, k)
- }
+ // TODO: We should check that these binds are all listed in the `Volumes`
+ // key since it doesn't make sense to define a `Binds` element for a
+ // container path which isn't defined as a volume
+ volumes := input.HostConfig.Binds
// Docker is more flexible about its input where podman throws
// away incorrectly formatted variables so we cannot reuse the