{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/44643289","id":44643289,"diff_hunk":"@@ -134,6 +135,158 @@ func (s *DockerSuite) TestRunAttachDetach(c *check.C) {\n \t}\n }\n \n+// TestRunDetach checks attaching and detaching with the escape sequence specified via flags.\n+func (s *DockerSuite) TestRunAttachDetachFromFlag(c *check.C) {\n+\tname := \"attach-detach\"\n+\tcmd := exec.Command(dockerBinary, \"run\", \"--name\", name, \"-it\", \"--detach-keys='ctrl-a,a'\", \"busybox\", \"cat\")\n+\tstdout, err := cmd.StdoutPipe()\n+\tif err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\tcpty, tty, err := pty.Open()\n+\tif err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\tdefer cpty.Close()\n+\tcmd.Stdin = tty\n+\tif err := cmd.Start(); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\tc.Assert(waitRun(name), check.IsNil)\n+\n+\tif _, err := cpty.Write([]byte(\"hello\\n\")); err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\n+\tout, err := bufio.NewReader(stdout).ReadString('\\n')\n+\tif err != nil {\n+\t\tc.Fatal(err)\n+\t}\n+\tif strings.TrimSpace(out) != \"hello\" {\n+\t\tc.Fatalf(\"expected 'hello', got %q\", out)\n+\t}\n+\n+\t// escape sequence\n+\tif _, err := cpty.Write([]byte{1}); err != nil {","path":"integration-cli/docker_cli_run_unix_test.go","position":53,"original_position":53,"commit_id":"cf01d9efe08245c682ce35697847c9b40e9ecdb4","original_commit_id":"cf01d9efe08245c682ce35697847c9b40e9ecdb4","user":{"login":"cpuguy83","id":799078,"avatar_url":"https://avatars.githubusercontent.com/u/799078?v=3","gravatar_id":"","url":"https://api.github.com/users/cpuguy83","html_url":"https://github.com/cpuguy83","followers_url":"https://api.github.com/users/cpuguy83/followers","following_url":"https://api.github.com/users/cpuguy83/following{/other_user}","gists_url":"https://api.github.com/users/cpuguy83/gists{/gist_id}","starred_url":"https://api.github.com/users/cpuguy83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpuguy83/subscriptions","organizations_url":"https://api.github.com/users/cpuguy83/orgs","repos_url":"https://api.github.com/users/cpuguy83/repos","events_url":"https://api.github.com/users/cpuguy83/events{/privacy}","received_events_url":"https://api.github.com/users/cpuguy83/received_events","type":"User","site_admin":false},"body":"maybe set these byte values to a var","created_at":"2015-11-12T10:44:36Z","updated_at":"2015-11-12T10:44:36Z","html_url":"https://github.com/docker/docker/pull/15666#discussion_r44643289","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/15666","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/44643289"},"html":{"href":"https://github.com/docker/docker/pull/15666#discussion_r44643289"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/15666"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/15666","id":42713932,"html_url":"https://github.com/docker/docker/pull/15666","diff_url":"https://github.com/docker/docker/pull/15666.diff","patch_url":"https://github.com/docker/docker/pull/15666.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/15666","number":15666,"state":"open","locked":false,"title":"Implement configurable escape key for attach/exec","user":{"login":"vdemeester","id":6508,"avatar_url":"https://avatars.githubusercontent.com/u/6508?v=3","gravatar_id":"","url":"https://api.github.com/users/vdemeester","html_url":"https://github.com/vdemeester","followers_url":"https://api.github.com/users/vdemeester/followers","following_url":"https://api.github.com/users/vdemeester/following{/other_user}","gists_url":"https://api.github.com/users/vdemeester/gists{/gist_id}","starred_url":"https://api.github.com/users/vdemeester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdemeester/subscriptions","organizations_url":"https://api.github.com/users/vdemeester/orgs","repos_url":"https://api.github.com/users/vdemeester/repos","events_url":"https://api.github.com/users/vdemeester/events{/privacy}","received_events_url":"https://api.github.com/users/vdemeester/received_events","type":"User","site_admin":false},"body":"Implement configurable escape keys (for `attach`, `exec`, `run` and `start`) using the client-side configuration and/or flags `--detach-keys`. This takes some pieces from #6460 from @vieux — except that this time it uses the client configuration (`~/.docker/config.json` for example). 🐧\r\n\r\n> This PR allows you to change the set of keys you have to type to detach in TTY mode, it can be less or more that two.\r\n> The basic ASCII table is supported, for example you can do: docker -d --detach-keys=\"ctrl-@\" and detach in one keystroke or docker -d --detach-keys=\"DEL,+\" if you don't like to have a ctrl key\r\n\r\nThe configuration looks like this :\r\n\r\n```json\r\n{\r\n    \"detachKey\": \"ctrl-a,a\"\r\n}\r\n```\r\n\r\nThe default keybinding stays the same : `ctrl-p ctrl-q` but it makes possible to configure something else.\r\n\r\nThere is room for improvements on the code that should be address during the design review process I think :\r\n- For `attach` command I use *queryString* (`detachKeys=ctrl-a%2Ca`) but for `exec` command I used `runConfig.ExecConfig`. That felt weird and it's not coherent, it should be the same thing for both. It could maybe be passed as HTTP Header, I don't know :sweat_smile: — that's why I'm putting this in review.\r\n- Right now, I don't validate the configuration client side, so if there is something wrong with the `detachKeys` passed, It's just logged and the defaults one are used.\r\n- Some refactoring is there is a little too much duplicated code for my taste (the `keys, err = term.ToBytes(detachKeys)` part is repeated few times..).\r\n- Probably add a `json:omitempty` for `DetachKeys` on `runconfig.ExecConfig`.\r\n\r\nWhat is still to do :\r\n- [X] Rebase it :sweat_smile:\r\n- [X] Implement flags by commands (`run`, `start`, `attach`, `exec`)\r\n- [X] Write some integration tests.\r\n- [X] Update some documentation.\r\n- [X] Update the commit message to make it more clear :sweat_smile:.\r\n\r\n🐸\r\n\r\nFixes #3519.\r\n\r\nSigned-off-by: Vincent Demeester <vincent@sbr.pm>","created_at":"2015-08-18T15:41:30Z","updated_at":"2015-11-12T10:44:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9911dcae4963847db0849e85e357e4116f2fc80c","assignee":null,"milestone":{"url":"https://api.github.com/repos/docker/docker/milestones/44","html_url":"https://github.com/docker/docker/milestones/1.10","labels_url":"https://api.github.com/repos/docker/docker/milestones/44/labels","id":1351533,"number":44,"title":"1.10","description":"","creator":{"login":"thaJeztah","id":1804568,"avatar_url":"https://avatars.githubusercontent.com/u/1804568?v=3","gravatar_id":"","url":"https://api.github.com/users/thaJeztah","html_url":"https://github.com/thaJeztah","followers_url":"https://api.github.com/users/thaJeztah/followers","following_url":"https://api.github.com/users/thaJeztah/following{/other_user}","gists_url":"https://api.github.com/users/thaJeztah/gists{/gist_id}","starred_url":"https://api.github.com/users/thaJeztah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaJeztah/subscriptions","organizations_url":"https://api.github.com/users/thaJeztah/orgs","repos_url":"https://api.github.com/users/thaJeztah/repos","events_url":"https://api.github.com/users/thaJeztah/events{/privacy}","received_events_url":"https://api.github.com/users/thaJeztah/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":5,"state":"open","created_at":"2015-10-12T18:21:55Z","updated_at":"2015-11-12T01:25:43Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/docker/docker/pulls/15666/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/15666/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/15666/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/cf01d9efe08245c682ce35697847c9b40e9ecdb4","head":{"label":"vdemeester:3519-configurable-escape","ref":"3519-configurable-escape","sha":"cf01d9efe08245c682ce35697847c9b40e9ecdb4","user":{"login":"vdemeester","id":6508,"avatar_url":"https://avatars.githubusercontent.com/u/6508?v=3","gravatar_id":"","url":"https://api.github.com/users/vdemeester","html_url":"https://github.com/vdemeester","followers_url":"https://api.github.com/users/vdemeester/followers","following_url":"https://api.github.com/users/vdemeester/following{/other_user}","gists_url":"https://api.github.com/users/vdemeester/gists{/gist_id}","starred_url":"https://api.github.com/users/vdemeester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdemeester/subscriptions","organizations_url":"https://api.github.com/users/vdemeester/orgs","repos_url":"https://api.github.com/users/vdemeester/repos","events_url":"https://api.github.com/users/vdemeester/events{/privacy}","received_events_url":"https://api.github.com/users/vdemeester/received_events","type":"User","site_admin":false},"repo":{"id":32953007,"name":"docker","full_name":"vdemeester/docker","owner":{"login":"vdemeester","id":6508,"avatar_url":"https://avatars.githubusercontent.com/u/6508?v=3","gravatar_id":"","url":"https://api.github.com/users/vdemeester","html_url":"https://github.com/vdemeester","followers_url":"https://api.github.com/users/vdemeester/followers","following_url":"https://api.github.com/users/vdemeester/following{/other_user}","gists_url":"https://api.github.com/users/vdemeester/gists{/gist_id}","starred_url":"https://api.github.com/users/vdemeester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdemeester/subscriptions","organizations_url":"https://api.github.com/users/vdemeester/orgs","repos_url":"https://api.github.com/users/vdemeester/repos","events_url":"https://api.github.com/users/vdemeester/events{/privacy}","received_events_url":"https://api.github.com/users/vdemeester/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vdemeester/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/vdemeester/docker","forks_url":"https://api.github.com/repos/vdemeester/docker/forks","keys_url":"https://api.github.com/repos/vdemeester/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vdemeester/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vdemeester/docker/teams","hooks_url":"https://api.github.com/repos/vdemeester/docker/hooks","issue_events_url":"https://api.github.com/repos/vdemeester/docker/issues/events{/number}","events_url":"https://api.github.com/repos/vdemeester/docker/events","assignees_url":"https://api.github.com/repos/vdemeester/docker/assignees{/user}","branches_url":"https://api.github.com/repos/vdemeester/docker/branches{/branch}","tags_url":"https://api.github.com/repos/vdemeester/docker/tags","blobs_url":"https://api.github.com/repos/vdemeester/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vdemeester/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vdemeester/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/vdemeester/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vdemeester/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/vdemeester/docker/languages","stargazers_url":"https://api.github.com/repos/vdemeester/docker/stargazers","contributors_url":"https://api.github.com/repos/vdemeester/docker/contributors","subscribers_url":"https://api.github.com/repos/vdemeester/docker/subscribers","subscription_url":"https://api.github.com/repos/vdemeester/docker/subscription","commits_url":"https://api.github.com/repos/vdemeester/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/vdemeester/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/vdemeester/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/vdemeester/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/vdemeester/docker/contents/{+path}","compare_url":"https://api.github.com/repos/vdemeester/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vdemeester/docker/merges","archive_url":"https://api.github.com/repos/vdemeester/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vdemeester/docker/downloads","issues_url":"https://api.github.com/repos/vdemeester/docker/issues{/number}","pulls_url":"https://api.github.com/repos/vdemeester/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/vdemeester/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/vdemeester/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vdemeester/docker/labels{/name}","releases_url":"https://api.github.com/repos/vdemeester/docker/releases{/id}","created_at":"2015-03-26T21:32:15Z","updated_at":"2015-05-08T12:20:26Z","pushed_at":"2015-11-12T08:14:29Z","git_url":"git://github.com/vdemeester/docker.git","ssh_url":"git@github.com:vdemeester/docker.git","clone_url":"https://github.com/vdemeester/docker.git","svn_url":"https://github.com/vdemeester/docker","homepage":"http://www.docker.com","size":75191,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"fb2bae5e162c91175f7cbc654de8e0fd132a0998","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-11-12T10:31:31Z","pushed_at":"2015-11-12T10:41:41Z","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":286333,"stargazers_count":26135,"watchers_count":26135,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7000,"mirror_url":null,"open_issues_count":1210,"forks":7000,"open_issues":1210,"watchers":26135,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/15666"},"html":{"href":"https://github.com/docker/docker/pull/15666"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/15666"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/15666/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/15666/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/15666/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/cf01d9efe08245c682ce35697847c9b40e9ecdb4"}}}}