func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) { // TODO Windows CI: Investigate further why this fails on Windows to Windows CI. testRequires(c, DaemonIsLinux) path := "/foo" if daemonPlatform == "windows" { path = `c:\foo` } name := "testing" config := map[string]interface{}{ "Image": "busybox", "Volumes": map[string]struct{}{path: {}}, } status, _, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/create?name="+name), config, daemonHost()) c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusCreated) bindPath := testutil.RandomTmpDirPath("test", daemonPlatform) config = map[string]interface{}{ "Binds": []string{bindPath + ":" + path}, } status, _, err = request.SockRequest("POST", formatV123StartAPIURL("/containers/"+name+"/start"), config, daemonHost()) c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusNoContent) pth, err := inspectMountSourceField(name, path) c.Assert(err, checker.IsNil) c.Assert(pth, checker.Equals, bindPath, check.Commentf("expected volume host path to be %s, got %s", bindPath, pth)) }
// Test for GH#10618 func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *check.C) { // TODO Windows to Windows CI - Port this testRequires(c, DaemonIsLinux) name := "testdups" config := map[string]interface{}{ "Image": "busybox", "Volumes": map[string]struct{}{"/tmp": {}}, } status, _, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/create?name="+name), config, daemonHost()) c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusCreated) bindPath1 := testutil.RandomTmpDirPath("test1", daemonPlatform) bindPath2 := testutil.RandomTmpDirPath("test2", daemonPlatform) config = map[string]interface{}{ "Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"}, } status, body, err := request.SockRequest("POST", formatV123StartAPIURL("/containers/"+name+"/start"), config, daemonHost()) c.Assert(err, checker.IsNil) c.Assert(status, checker.Equals, http.StatusInternalServerError) c.Assert(string(body), checker.Contains, "Duplicate mount point", check.Commentf("Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(body), err)) }