Attach to an Existing Container

Hi all,

I created an Ubuntu container, and then got out of it using Ctrl+C. I tried $ docker restart [image], and then I saw the correct container ID. Then, I tried running $ docker attach [container ID], but then I got this error messga: You cannot attach to a stopped container, start it first. Then, I verified this by runnign $ docker ps, and I did not see the container I restarted earlier.

I have no idea what’s going on. If anyone can help, I would really appreciate it.


From the description, it seems pretty certain that the container exited after your docker restart command. You should be able to see the container using the “docker ps -a” command, which will also show you the exit code. To investigate why it exited, you can run the "docker logs " command to see what output there is.


Control+c kills the container. You have to exit with control+p, control+q if you want to deattach without stopping the container.