Interactive session in a Docker container

Published on

Opening a bash session in a given container:

docker exec -it <container-name> /bin/bash

In case the image is more bare bones you can still open a shell session:

docker exec -it <container-name> /bin/sh

You can only open sessions in containers that are running so check their status with docker ps before trying to open the session.

If you are not sure about the container names you can list them with:

docker ps --format "{{.Names}}"