are connected to the container as root (in the container’s
namespace). If you execute the bash ps command, you
can see that there are only two things: the bash shell and
the ps command that you just ran. This highlights the
container’s isolation from the host OS:
root@a583eac3cadb:/# ps
PID TTY TIME CMD
1 pts/0 00:00:00 bash
11 pts/0 00:00:00 ps
To disconnect from the container, you can type exit, but
that would stop the container. If you want to leave it
running, you can hold down Ctrl and press P and then
while still holding Ctrl press Q. This sequence drops you
back to the host OS and leaves the container running.
From the host OS, you can type docker container ls to
see that your container is actively running:
Click here to view code image
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
a583eac3cadb ubuntu "bash" About a minute ago
Up About a minute musing_bartik
If you want to reconnect to the container, you can use the
container ID or the assigned name to attach to the
container and interact with it again:
Click here to view code image
$ docker container attach a583eac3cadb
root@a583eac3cadb:/#
The inspect and logs commands are two very useful
commands for troubleshooting a container. inspect
generates a ton of information—pretty much everything