{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/14391","labels_url":"https://api.github.com/repos/docker/docker/issues/14391/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/14391/comments","events_url":"https://api.github.com/repos/docker/docker/issues/14391/events","html_url":"https://github.com/docker/docker/issues/14391","id":93005791,"number":14391,"title":"docker run -t -i and NO option (-d), terminal closed -> container still lives","user":{"login":"JonasT","id":1573352,"avatar_url":"https://avatars.githubusercontent.com/u/1573352?v=3","gravatar_id":"","url":"https://api.github.com/users/JonasT","html_url":"https://github.com/JonasT","followers_url":"https://api.github.com/users/JonasT/followers","following_url":"https://api.github.com/users/JonasT/following{/other_user}","gists_url":"https://api.github.com/users/JonasT/gists{/gist_id}","starred_url":"https://api.github.com/users/JonasT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JonasT/subscriptions","organizations_url":"https://api.github.com/users/JonasT/orgs","repos_url":"https://api.github.com/users/JonasT/repos","events_url":"https://api.github.com/users/JonasT/events{/privacy}","received_events_url":"https://api.github.com/users/JonasT/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-04T11:58:01Z","updated_at":"2015-07-06T00:03:26Z","closed_at":null,"body":"When I run something with ```\r\ndocker run -t -i``` and NO option ```\r\n-d```, if I close the terminal with the running thing in it the container still lives afterwards (confirmed with ```\r\ndocker ps```). This runs totally contrary to the intuition of a non-detached thing running in my terminal which behaves like its bound to it like a regular process - but then unexpectedly survives killing the terminal, which can lead to unexpected background stuff still running when a user would assume it to be terminated.\r\n\r\nRemember the times when you ssh'ed into a server and ran ```\r\napt-get upgrade``` through the ssh session, but then you forgot to use ```\r\nnohup``` and your session died due to connection problems and the upgrade process was instant-killed during the upgrade since it was bound to your ssh terminal? Yes, this is what I expected to happen here. But it's not what docker was doing.\r\n\r\nThis behavior is very useful when I *do* want a process to stop, and it's somewhat unexpected ```\r\ndocker run``` doesn't seem to be following this behavior since 99% of all other non-detached linux commands and processes do.\r\n\r\nIs this intended? Is this a bug? Whatever it is, I think it should be changed.\r\n\r\n**Steps to reproduce:**\r\n1. Download http://www.homeofjones.de/temp/panda-fedora.zip and unzip\r\n2. Make sure git is installed\r\n3. Examine build.sh script and check the simple commands it does (basically git clone panda to a subfolder, then docker build of the Dockerfile, then docker run to build it)\r\n4. Run build.sh and wait until it is in the panda3d build process (this might take a few minutes)\r\n5. Close the terminal before the build completes (DO NOT CTRL+C, just use the close button and confirm any warnings that you might get about the terminal still running a process)\r\n6. Type in ```docker ps```\r\n\r\nActual result: docker container is still running despite the terminal and .sh being terminated.\r\n\r\nExpected result: docker container is turned off.\r\n\r\ndocker version:\r\n\r\n```\r\nClient version: 1.7.0\r\nClient API version: 1.19\r\nGo version (client): go1.4.2\r\nGit commit (client): 0baf609\r\nOS/Arch (client): linux/amd64\r\nServer version: 1.7.0\r\nServer API version: 1.19\r\nGo version (server): go1.4.2\r\nGit commit (server): 0baf609\r\nOS/Arch (server): linux/amd64\r\n```\r\n\r\ndocker info:\r\n\r\n```\r\nContainers: 123\r\nImages: 197\r\nStorage Driver: aufs\r\n Root Dir: /var/lib/docker/aufs\r\n Backing Filesystem: extfs\r\n Dirs: 443\r\n Dirperm1 Supported: true\r\nExecution Driver: native-0.2\r\nLogging Driver: json-file\r\nKernel Version: 3.19.0-18-generic\r\nOperating System: Ubuntu 15.04\r\nCPUs: 4\r\nTotal Memory: 7.682 GiB\r\nName: cyberman\r\nID: JL55:4BBV:7VUZ:DBO2:NWVV:RE62:OQNK:IV75:THXS:SQL4:HLH3:FTIA\r\nWARNING: No swap limit support\r\n```\r\n\r\nuname -a: ```\r\nLinux cyberman 3.19.0-18-generic #18-Ubuntu SMP Tue May 19 18:31:35 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux```"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/118681361","html_url":"https://github.com/docker/docker/issues/14391#issuecomment-118681361","issue_url":"https://api.github.com/repos/docker/docker/issues/14391","id":118681361,"user":{"login":"phemmer","id":1826947,"avatar_url":"https://avatars.githubusercontent.com/u/1826947?v=3","gravatar_id":"","url":"https://api.github.com/users/phemmer","html_url":"https://github.com/phemmer","followers_url":"https://api.github.com/users/phemmer/followers","following_url":"https://api.github.com/users/phemmer/following{/other_user}","gists_url":"https://api.github.com/users/phemmer/gists{/gist_id}","starred_url":"https://api.github.com/users/phemmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phemmer/subscriptions","organizations_url":"https://api.github.com/users/phemmer/orgs","repos_url":"https://api.github.com/users/phemmer/repos","events_url":"https://api.github.com/users/phemmer/events{/privacy}","received_events_url":"https://api.github.com/users/phemmer/received_events","type":"User","site_admin":false},"created_at":"2015-07-06T00:03:26Z","updated_at":"2015-07-06T00:03:26Z","body":"You say you are using a shell script to launch the container. If so, this is very easy to accomplish:\r\n\r\n```\r\ncid=\"$(docker run -tid foo)\"\r\ntrap \"docker kill $cid\" EXIT\r\ndocker logs -f $cid\r\n```\r\n*(or `docker attach $cid` instead of `docker logs`)*\r\n\r\nIf the shell script exits for any reason, it runs `docker kill $cid`."}}