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
Step 4: To exit bash without leaving bash running in a rogue process
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.
Latest posts by scmgalaxy K (see all)
- Use of runtime variables to save into another variable using register in Ansible - September 6, 2018
- Ansible & Ansible Tower Variable Precedence Hierarchy - September 6, 2018
- How to use template in Ansible? - September 6, 2018