{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/11957","labels_url":"https://api.github.com/repos/docker/docker/issues/11957/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/11957/comments","events_url":"https://api.github.com/repos/docker/docker/issues/11957/events","html_url":"https://github.com/docker/docker/issues/11957","id":65465224,"number":11957,"title":"docker run -i never exits if spawned by other process for reading / writing using pipe","user":{"login":"detomastah","id":112113,"avatar_url":"https://avatars.githubusercontent.com/u/112113?v=3","gravatar_id":"","url":"https://api.github.com/users/detomastah","html_url":"https://github.com/detomastah","followers_url":"https://api.github.com/users/detomastah/followers","following_url":"https://api.github.com/users/detomastah/following{/other_user}","gists_url":"https://api.github.com/users/detomastah/gists{/gist_id}","starred_url":"https://api.github.com/users/detomastah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detomastah/subscriptions","organizations_url":"https://api.github.com/users/detomastah/orgs","repos_url":"https://api.github.com/users/detomastah/repos","events_url":"https://api.github.com/users/detomastah/events{/privacy}","received_events_url":"https://api.github.com/users/detomastah/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-31T14:29:29Z","updated_at":"2015-04-02T14:23:36Z","closed_at":null,"body":"Description of problem:\r\n\r\nWhen interacting with docker container through popen, the dockerized process hangs. The process is visible in system process list `ps aux | grep docker`, but `docker ps` shows that it exited.\r\nWhen I pass something onto `stdin`, the process exits. The problem is easily reproducible, I tried on Docker 1.4.1 and 1.5.0 and result was the same. Scroll down to see the example code how to reproduce it.\r\n\r\n`docker version`:\r\n\r\n```\r\nClient version: 1.5.0\r\nClient API version: 1.17\r\nGo version (client): go1.4.1\r\nGit commit (client): a8a31ef\r\nOS/Arch (client): linux/amd64\r\nServer version: 1.5.0\r\nServer API version: 1.17\r\nGo version (server): go1.4.1\r\nGit commit (server): a8a31ef\r\n```\r\n\r\n`docker info`:\r\n\r\n```\r\nContainers: 26\r\nImages: 143\r\nStorage Driver: aufs\r\n Root Dir: /var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 216\r\nExecution Driver: native-0.2\r\nKernel Version: 3.13.0-43-generic\r\nOperating System: Ubuntu 14.04.1 LTS\r\nCPUs: 4\r\nTotal Memory: 7.633 GiB\r\nName: lukasz-ThinkPad-T420\r\nID: LKJ2:DWR4:JPLK:6TCQ:JZ4K:CQWB:PIGH:PFM4:FAFI:OTHH:QESL:OIFC\r\nWARNING: No swap limit support\r\n```\r\n\r\n`uname -a`: \r\n\r\n`Linux lukasz-ThinkPad-T420 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux`\r\n\r\n\r\nEnvironment details: physical, Ubuntu 14.04\r\n\r\nHow reproducible:\r\n\r\nCreate test.rb file with following code:\r\n\r\n```ruby\r\ncommand = 'docker run -i ubuntu /bin/ls'\r\n\r\nin_r, in_w = IO.pipe\r\nout_r, out_w = IO.pipe\r\nerr_r, err_w = IO.pipe\r\n\r\nin_w.sync = true\r\n\r\npid = spawn(\r\n  command,\r\n  in: in_r,\r\n  out: out_w,\r\n  err: err_w\r\n)\r\n\r\n[in_r, out_w, err_w].each {|io| io.close }\r\n\r\nputs \"One: #{pid}\"\r\n\r\nProcess.waitpid(pid)\r\n\r\nputs \"Two\"\r\n```\r\n\r\nThen run:\r\n\r\n`ruby test.rb`\r\n\r\nActual Results:\r\n\r\nYou will see that it never exits, never returns \"Two\". Dockerized `/bin/ls` process is still running but running `docker ps --all` shows that container immediately exited. If you remove `-i` flag is starts to work as expected but communication with process is lost.\r\n\r\nExpected Results:\r\n\r\n`ruby test.rb` should exit immediately returning \"Two\"\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/88926629","html_url":"https://github.com/docker/docker/issues/11957#issuecomment-88926629","issue_url":"https://api.github.com/repos/docker/docker/issues/11957","id":88926629,"user":{"login":"detomastah","id":112113,"avatar_url":"https://avatars.githubusercontent.com/u/112113?v=3","gravatar_id":"","url":"https://api.github.com/users/detomastah","html_url":"https://github.com/detomastah","followers_url":"https://api.github.com/users/detomastah/followers","following_url":"https://api.github.com/users/detomastah/following{/other_user}","gists_url":"https://api.github.com/users/detomastah/gists{/gist_id}","starred_url":"https://api.github.com/users/detomastah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/detomastah/subscriptions","organizations_url":"https://api.github.com/users/detomastah/orgs","repos_url":"https://api.github.com/users/detomastah/repos","events_url":"https://api.github.com/users/detomastah/events{/privacy}","received_events_url":"https://api.github.com/users/detomastah/received_events","type":"User","site_admin":false},"created_at":"2015-04-02T14:23:36Z","updated_at":"2015-04-02T14:23:36Z","body":"@vdemeester Thanks for response! Unfortunately you are closing ability to write to `stdin` of the running process - it works, but this way you are essentially running it without `-i`. Running it with `-it` does not work for every command (for example `mruby`) - you'll get error: `cannot enable tty mode for non-tty input`"}}