Adding some more thoughts here as I was playing around with this myself.
Let's say I want to work with 3 docker containers :
blong@mycomputer:~$ docker run --name ubuntuContainer1 -itd ubuntu
2ce602710fb9b84b6530e5a1072961627e91731aba8f8b019f346fc78df08d7c
blong@mycomputer:~$ docker run --name ubuntuContainer2 -itd ubuntu
e32b0eb72456fc23222f3915c91afc77e06a7e37a073b11f7088fabe8fa4bf20
blong@mycomputer:~$ docker run --name ubuntuContainer3 -itd ubuntu
40574f704dceb0378f48ebe01d014d598434093d649be13573911d9833d9825d
See that they keep running, even though I didn't ask to run /bin/bash explicitly
blong@mycomputer:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40574f704dce ubuntu "/bin/bash" 2 seconds ago Up 1 seconds ubuntuContainer3
e32b0eb72456 ubuntu "/bin/bash" 5 seconds ago Up 4 seconds ubuntuContainer2
2ce602710fb9 ubuntu "/bin/bash" 8 seconds ago Up 7 seconds ubuntuContainer1
I can shell into the containers
blong@mycomputer:~$ docker attach ubuntuContainer1
root@2ce602710fb9:/#
I can execute commands (e.g. installing packages) in the container
root@2ce602710fb9:/# apt-get update
# ... omitting output
root@2ce602710fb9:/# apt-get install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libc-ares2 libv8-3.14.5
The following NEW packages will be installed:
libc-ares2 libv8-3.14.5 nodejs
0 upgraded, 3 newly installed, 0 to remove and 5 not upgraded.
Need to get 1912 kB of archives.
After this operation, 7538 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
# ... omitting output
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
root@2ce602710fb9:/# nodejs --version
v0.10.25
Afterwards, I can exit, and keep everything running by pressing CTRL-p CTRL-q
root@2ce602710fb9:/# blong@mycomputer:~/$
blong@mycomputer:~/$
See also: