Skip to content
Edgar Pino
TwitterHomepage

How To SSH Into Docker Container

1 min read

Problem

Sometimes you need you access a container to debug or to access a command line tool available inside.

Solution

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

Note the --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