How To SSH Into Docker Container
— 1 min read
Sometimes you need you access a container to debug or to access a command line tool available inside.
When the container is running you can use the exec Docker command to run a command in a running container. If you are using the Ubuntu image then this is how you SSH or bash into it a Docker container:
docker exec -it ubuntu_container bash
--it option which allows you to keep STDIN open even if not attached and allocate a pseudo-TTY. You can also run a command under given user by using the
-u option. See the official exec Docker documentation for more info.
If the above does not work for you or if you are using a different Linux distribution the try the following:
docker exec -it some_container /bin/bash