{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/29600980","id":29600980,"diff_hunk":"@@ -1040,3 +1041,125 @@ func (s *DockerSuite) TestContainerApiCopyContainerNotFound(c *check.C) {\n \tc.Assert(err, check.IsNil)\n \tc.Assert(status, check.Equals, http.StatusNotFound)\n }\n+\n+func (s *DockerSuite) TestContainerApiDelete(c *check.C) {\n+\trunCmd := exec.Command(dockerBinary, \"run\", \"-d\", \"busybox\", \"top\")\n+\tout, _, err := runCommandWithOutput(runCmd)\n+\tc.Assert(err, check.IsNil)\n+\n+\tid := strings.TrimSpace(out)\n+\tif err := waitRun(id); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\tstopCmd := exec.Command(dockerBinary, \"stop\", id)\n+\t_, err = runCommand(stopCmd)\n+\tc.Assert(err, check.IsNil)\n+\n+\tstatus, _, err := sockRequest(\"DELETE\", \"/containers/\"+id, nil)\n+\tc.Assert(err, check.IsNil)\n+\tc.Assert(status, check.Equals, http.StatusNoContent)\n+}\n+\n+func (s *DockerSuite) TestContainerApiDeleteNotExist(c *check.C) {\n+\tstatus, body, err := sockRequest(\"DELETE\", \"/containers/doesnotexist\", nil)\n+\tc.Assert(err, check.IsNil)\n+\tc.Assert(status, check.Equals, http.StatusNotFound)\n+\tc.Assert(string(body), check.Matches, \"no such id: doesnotexist\\n\")\n+}\n+\n+func (s *DockerSuite) TestContainerApiDeleteForce(c *check.C) {\n+\trunCmd := exec.Command(dockerBinary, \"run\", \"-d\", \"busybox\", \"top\")\n+\tout, _, err := runCommandWithOutput(runCmd)\n+\tc.Assert(err, check.IsNil)\n+\n+\tid := strings.TrimSpace(out)\n+\tif err := waitRun(id); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\tstatus, _, err := sockRequest(\"DELETE\", \"/containers/\"+id+\"?force=1\", nil)\n+\tc.Assert(err, check.IsNil)\n+\tc.Assert(status, check.Equals, http.StatusNoContent)\n+}\n+\n+func (s *DockerSuite) TestContainerApiDeleteRemoveLinks(c *check.C) {\n+\trunCmd := exec.Command(dockerBinary, \"run\", \"-d\", \"--name\", \"tlink1\", \"busybox\", \"top\")\n+\tout, _, err := runCommandWithOutput(runCmd)\n+\tc.Assert(err, check.IsNil)\n+\n+\tid := strings.TrimSpace(out)\n+\tif err := waitRun(id); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\trunCmd = exec.Command(dockerBinary, \"run\", \"--link\", \"tlink1:tlink1\", \"--name\", \"tlink2\", \"-d\", \"busybox\", \"top\")\n+\tout, _, err = runCommandWithOutput(runCmd)\n+\tc.Assert(err, check.IsNil)\n+\n+\tid2 := strings.TrimSpace(out)\n+\tif err := waitRun(id2); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\tlinks, err := inspectFieldJSON(id2, \"HostConfig.Links\")\n+\tc.Assert(err, check.IsNil)\n+\n+\tif links != \"[\\\"/tlink1:/tlink2/tlink1\\\"]\" {\n+\t\tc.Fatal(\"expected to have links between containers\")\n+\t}\n+\n+\tstatus, _, err := sockRequest(\"DELETE\", \"/containers/tlink2/tlink1?link=1\", nil)\n+\tc.Assert(err, check.IsNil)\n+\tc.Assert(status, check.Equals, http.StatusNoContent)\n+\n+\tlinksPostRm, err := inspectFieldJSON(id2, \"HostConfig.Links\")\n+\tc.Assert(err, check.IsNil)\n+\n+\tif linksPostRm != \"null\" {\n+\t\tc.Fatal(\"call to api deleteContainer links should have removed the specified links\")\n+\t}\n+}\n+\n+func (s *DockerSuite) TestContainerApiDeleteConflict(c *check.C) {\n+\trunCmd := exec.Command(dockerBinary, \"run\", \"-d\", \"busybox\", \"top\")\n+\tout, _, err := runCommandWithOutput(runCmd)\n+\tc.Assert(err, check.IsNil)\n+\n+\tid := strings.TrimSpace(out)\n+\tif err := waitRun(id); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\tstatus, _, err := sockRequest(\"DELETE\", \"/containers/\"+id, nil)\n+\tc.Assert(status, check.Equals, http.StatusConflict)\n+\tc.Assert(err, check.IsNil)\n+}\n+\n+func (s *DockerSuite) TestContainerApiDeleteRemoveVolume(c *check.C) {\n+\ttestRequires(c, SameHostDaemon)\n+\n+\trunCmd := exec.Command(dockerBinary, \"run\", \"-d\", \"-v\", \"/testvolume\", \"busybox\", \"top\")\n+\tout, _, err := runCommandWithOutput(runCmd)\n+\tc.Assert(err, check.IsNil)\n+\n+\tid := strings.TrimSpace(out)\n+\tif err := waitRun(id); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\tvol, err := inspectFieldMap(id, \"Volumes\", \"/testvolume\")\n+\tc.Assert(err, check.IsNil)\n+\n+\tif _, err := os.Stat(vol); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\tstatus, _, err := sockRequest(\"DELETE\", \"/containers/\"+id+\"?v=1&force=1\", nil)\n+\tc.Assert(status, check.Equals, http.StatusNoContent)\n+\tc.Assert(err, check.IsNil)\n+\n+\tif _, err := os.Stat(vol); !os.IsNotExist(err) {","path":"integration-cli/docker_api_containers_test.go","position":130,"original_position":130,"commit_id":"276c3cdbba4b1edd0219f84efb677cac056759c5","original_commit_id":"276c3cdbba4b1edd0219f84efb677cac056759c5","user":{"login":"tiborvass","id":827131,"avatar_url":"https://avatars.githubusercontent.com/u/827131?v=3","gravatar_id":"","url":"https://api.github.com/users/tiborvass","html_url":"https://github.com/tiborvass","followers_url":"https://api.github.com/users/tiborvass/followers","following_url":"https://api.github.com/users/tiborvass/following{/other_user}","gists_url":"https://api.github.com/users/tiborvass/gists{/gist_id}","starred_url":"https://api.github.com/users/tiborvass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiborvass/subscriptions","organizations_url":"https://api.github.com/users/tiborvass/orgs","repos_url":"https://api.github.com/users/tiborvass/repos","events_url":"https://api.github.com/users/tiborvass/events{/privacy}","received_events_url":"https://api.github.com/users/tiborvass/received_events","type":"User","site_admin":false},"body":"fair enough","created_at":"2015-05-04T16:54:44Z","updated_at":"2015-05-04T16:54:44Z","html_url":"https://github.com/docker/docker/pull/12948#discussion_r29600980","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/12948","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/29600980"},"html":{"href":"https://github.com/docker/docker/pull/12948#discussion_r29600980"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/12948"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/12948","id":34600832,"html_url":"https://github.com/docker/docker/pull/12948","diff_url":"https://github.com/docker/docker/pull/12948.diff","patch_url":"https://github.com/docker/docker/pull/12948.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/12948","number":12948,"state":"open","locked":false,"title":"Add tests for API container delete","user":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Antonio Murdaca <me@runcom.ninja>","created_at":"2015-05-03T12:55:45Z","updated_at":"2015-05-04T16:54:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5db5e1e7211d3a84baf2ee2b7c47af4f56eb9de0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/12948/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/12948/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/12948/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/276c3cdbba4b1edd0219f84efb677cac056759c5","head":{"label":"runcom:api-tests-container-delete","ref":"api-tests-container-delete","sha":"276c3cdbba4b1edd0219f84efb677cac056759c5","user":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"repo":{"id":32636176,"name":"docker","full_name":"runcom/docker","owner":{"login":"runcom","id":849915,"avatar_url":"https://avatars.githubusercontent.com/u/849915?v=3","gravatar_id":"","url":"https://api.github.com/users/runcom","html_url":"https://github.com/runcom","followers_url":"https://api.github.com/users/runcom/followers","following_url":"https://api.github.com/users/runcom/following{/other_user}","gists_url":"https://api.github.com/users/runcom/gists{/gist_id}","starred_url":"https://api.github.com/users/runcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runcom/subscriptions","organizations_url":"https://api.github.com/users/runcom/orgs","repos_url":"https://api.github.com/users/runcom/repos","events_url":"https://api.github.com/users/runcom/events{/privacy}","received_events_url":"https://api.github.com/users/runcom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/runcom/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/runcom/docker","forks_url":"https://api.github.com/repos/runcom/docker/forks","keys_url":"https://api.github.com/repos/runcom/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runcom/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runcom/docker/teams","hooks_url":"https://api.github.com/repos/runcom/docker/hooks","issue_events_url":"https://api.github.com/repos/runcom/docker/issues/events{/number}","events_url":"https://api.github.com/repos/runcom/docker/events","assignees_url":"https://api.github.com/repos/runcom/docker/assignees{/user}","branches_url":"https://api.github.com/repos/runcom/docker/branches{/branch}","tags_url":"https://api.github.com/repos/runcom/docker/tags","blobs_url":"https://api.github.com/repos/runcom/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runcom/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runcom/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/runcom/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runcom/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/runcom/docker/languages","stargazers_url":"https://api.github.com/repos/runcom/docker/stargazers","contributors_url":"https://api.github.com/repos/runcom/docker/contributors","subscribers_url":"https://api.github.com/repos/runcom/docker/subscribers","subscription_url":"https://api.github.com/repos/runcom/docker/subscription","commits_url":"https://api.github.com/repos/runcom/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/runcom/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/runcom/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/runcom/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/runcom/docker/contents/{+path}","compare_url":"https://api.github.com/repos/runcom/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runcom/docker/merges","archive_url":"https://api.github.com/repos/runcom/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runcom/docker/downloads","issues_url":"https://api.github.com/repos/runcom/docker/issues{/number}","pulls_url":"https://api.github.com/repos/runcom/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/runcom/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/runcom/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runcom/docker/labels{/name}","releases_url":"https://api.github.com/repos/runcom/docker/releases{/id}","created_at":"2015-03-21T14:55:26Z","updated_at":"2015-05-03T16:06:42Z","pushed_at":"2015-05-03T17:30:50Z","git_url":"git://github.com/runcom/docker.git","ssh_url":"git@github.com:runcom/docker.git","clone_url":"https://github.com/runcom/docker.git","svn_url":"https://github.com/runcom/docker","homepage":"http://www.docker.com","size":53405,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"15313dfdf38ecaa0dc93005f1c3824491fbb3b96","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","created_at":"2013-01-18T18:10:57Z","updated_at":"2015-05-04T16:40:05Z","pushed_at":"2015-05-04T16:46:42Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":193372,"stargazers_count":21334,"watchers_count":21334,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4972,"mirror_url":null,"open_issues_count":958,"forks":4972,"open_issues":958,"watchers":21334,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/12948"},"html":{"href":"https://github.com/docker/docker/pull/12948"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/12948"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/12948/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/12948/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/12948/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/276c3cdbba4b1edd0219f84efb677cac056759c5"}}}}