Connecting an interactive session to a running docker container.

Posted: 9 August 2018 in Docker

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 -

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s