+91 700 483 5930   +91 810 584 3520    info@scmgalaxy.com
Sign In or Register
Not Registered Yet?

Join Now! It's FREE. Get full access and benefit from this site

Reset My password - Remind Me My username

Remember me
scmGalaxy logo

How to get bash or ssh into a running container in background mode?

How to get bash or ssh into a running container in background mode?
Step 1: First of all, try to find your active container by running
# docker ps
# docker ps -a
Step 2: If the container is not running,
# docker start your_id
Step 3: If we use attach we can use only one instance of shell.
# sudo docker attach 665b4a1e17b6 #by ID
# sudo docker attach loving_heisenberg #by Name
If we want open new terminal with new instance of container's shell, we just need run the following:
# sudo docker exec -i -t 2e56ad1705b1 /bin/bash #by ID
# sudo docker exec -i -t loving_heisenberg /bin/bash #by Name
# root@665b4a1e17b6:/#
Step 4: To exit bash without leaving bash running in a rogue process
# exit
A reminder for boot2docker users: remove sudo
If you are using docker in Linux, you will have to use sudo along with docker commands.
You should try not to run commands as sudo, rather add your user to the docker group and just run normally.
Rate this item
(2 votes)
Rajesh Kumar


Total, Over 12 years of extensive experience in the Software Configuration Management domain having depth knowledge of DevOps, Continuous Integration and Delivery, Configuration Management, Build and Installer, Release Management and Application Management.