From 9fe3153c0c8c7aba80975b6e080935d40198e7c9 Mon Sep 17 00:00:00 2001 From: maybe-sybr <58414429+maybe-sybr@users.noreply.github.com> Date: Wed, 24 Jun 2020 16:01:17 +1000 Subject: APIv2:fix: Get volumes from `Binds` when creating This change ensures that we pull volume bind specification strings from the correct spot in the POSTed data when creating containers. We should probably canity check that the mapping keys in `Volumes` are a superset of the binds listed in `HostConfig.Binds` but this cheap change removes an annoying behaviour where named volumes or host mount would be silently replaced with newly created anonymous volumes. Signed-off-by: Matt Brindley <58414429+maybe-sybr@users.noreply.github.com> --- pkg/api/handlers/compat/containers_create.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pkg/api/handlers/compat/containers_create.go') diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index 8034a529c..a4511b3b0 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -135,10 +135,10 @@ func makeCreateConfig(containerConfig *config.Config, input handlers.CreateConta 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 -- cgit v1.2.3-54-g00ecf