Docker How To Attach To Running Container
It is easy to attach to a running Docker container.
You can attach to a running container like this. It will need to be running a shell.
docker attach smelly-hippo
You can use these key sequences with this type of connection:
CTRL-c | kill the container |
CTRL-p CTRL-q | detach from container and keep it running |
Using the attach command will only connect to one instance of the shell even if you connect multiple times at once. It also requires the container to be running with a shell.
Alternatively, you can also use docker exec to run a shell on a container:
docker exec -it smelly-hippo bash
This has the advantage of allowing you to run multiple instances of the shell.