Thoughts, stories and ideas.

Connecting an interactive session to a running docker container

To connect to a running docker container and change files residing within the container you need to start an interactive session. First list all the running containers with the following command:

docker ps

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS 08a9a1701107        rabbitmq:3.7.3-management   "docker-entrypoint.s…"   3 hours ago         Up About an hour

Docker will list all your running container as seen above. The column CONTAINER ID is important and we will be using this ID to connect to the interactive session of that container. To connect to the container enter the following command:

docker exec -it 08a9a1701107 su -

alternative for the CONTAINER ID is the container name if you happen to know this. In my case this would be:

docker exec -it rabbitmq-docker su -

Subscribe to MichaelWandzik.com

Sign up now to get access to the library of members-only issues.
Jamie Larson
Subscribe