You can either attach to it, or run an exec-command, such as: docker exec -ti CONTAINER_ID bash The same command from above would look like this: docker run -it -d busybox sh If you start a container, and need to detach from itįrequently, consider running it directly in the background, by starting it in “detached mode” with -d. You can attach to it later using docker attach, if you need to interact with the container more. Which keeps the container running but frees up your terminal. You turn interactive mode to daemon mode, You have to use two combinations, one after the other: ctrl+p followed by ctrl+q. The effect will be, as if you had started it with the -d flag in the first place. You can detach from an interactive Docker session without exiting the container. Then you can exit the shell, or the container might exit already.īut what if you want to keep the container running, but without occupying your terminal? Keep Your Container Running In The Background If there’s a non-shell process running, theĬombination is ctrl+c to interrupt it. TL DR: press ctrl+c then ctrl+d - that means, keep the ctrl key pressed, type a c, and let go of ctrl. If you want to stop and exit the container, and are in an interactive, responsive shell - press ctrl+d to exit the session. See the '057e2d19b121' host name? Just Stopping the Container