diff --git a/daemon/volumes.go b/daemon/volumes.go index ad3c96a945..c396843831 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -95,12 +95,12 @@ func (daemon *Daemon) registerMountPoints(container *container.Container, hostCo for _, v := range hostConfig.VolumesFrom { containerID, mode, err := parser.ParseVolumesFrom(v) if err != nil { - return err + return errdefs.InvalidParameter(err) } c, err := daemon.GetContainer(containerID) if err != nil { - return err + return errdefs.InvalidParameter(err) } for _, m := range c.MountPoints { diff --git a/integration/container/create_test.go b/integration/container/create_test.go index f3e1e348b0..0d7b75465b 100644 --- a/integration/container/create_test.go +++ b/integration/container/create_test.go @@ -621,3 +621,18 @@ func TestCreateDifferentPlatform(t *testing.T) { assert.Assert(t, client.IsErrNotFound(err), err) }) } + +func TestCreateVolumesFromNonExistingContainer(t *testing.T) { + defer setupTest(t)() + cli := testEnv.APIClient() + + _, err := cli.ContainerCreate( + context.Background(), + &container.Config{Image: "busybox"}, + &container.HostConfig{VolumesFrom: []string{"nosuchcontainer"}}, + nil, + nil, + "", + ) + assert.Check(t, errdefs.IsInvalidParameter(err)) +}