Friday, September 26, 2014

Attaching to docker container

You launched your Docker container with
sudo docker –run –I –t –name grey_cat centos /bin/bash

This creates the container name “grey_cat” from base image “centos” and ran the bash shell inside it, the container’s is presented.

Once you are done with the container you type “exit” which stop the container and get back to you host shell.
So what happened to container? The container still exists; we can show a list of current containers using the docker ps -a command

To start the stopped container
sudo docker start grey_cat

This start the container with the same options when it was launched with docker run command.

To attach to the interactive session we can use attach command
sudo docker attach grey_cat

You might need to Enter to get the command prompt.

No comments:

Post a Comment