Skip to content

Commit 46b9f68

Browse files
authored
Create attach-bash-to-running-container.md
1 parent d21c4dc commit 46b9f68

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Attaching a bash shell to a running Docker container
2+
3+
Use `docker ps` to find the container ID:
4+
5+
$ docker ps
6+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7+
81b2ad3194cb alexdebrie/livegrep-base:1 "/livegrep-github-re…" 2 minutes ago Up 2 minutes compassionate_yalow
8+
9+
Run `docker exec -it ID bash` to start a bash session in that container:
10+
11+
$ docker exec -it 81b2ad3194cb bash
12+
13+
I made the mistake of using `docker attach 81b2ad3194cb` first, which attaches you to the command running as CMD in that conatiner, and means that if you hit `Ctrl+C` you exit that command and terminate the container!

0 commit comments

Comments
 (0)