First of all, let’s run a simple and the most popular hello-world
image into a container.
[email protected]:~$ docker run hello-world
Hello from Docker!
I have pasted a short snippet of the output. You’ll see a complete message from the hello-world
Docker image.
We already did that before while we installed Docker on Ubuntu 18.04 and Ubuntu 20.04.
Here, we’ve run a hello-world
container. The container ran and exited at the same time.
In order to see the running containers, we use the docker ps
command. It’s important to know that this command will only show us the containers that are running at the moment. We won’t see the containers that were exited.
For that purpose, we will use the following command:
[email protected]:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f2508d6d3be3 hello-world "/hello" 54 seconds ago Exited (0) 52 seconds ago naughty_bell
Did you see that?
The container was created and exited after few seconds. It will keep running in the foreground.