Linux Labs

Containers: Docker and compose / Stage 1 of 11

Image, container and process

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 6 · on a machine · 6 min

Image and container

The web container has not gone anywhere. This step covers how a container differs from an image and where to look for a stopped container.

An image is a program's files with everything it needs to run, plus the command to start by default. docker images lists the images on the machine. busybox is a small image with a set of utilities, the httpd web server among them.

A container is a run of an image. Docker takes the image's files, gives the container a name and runs a command in it. One image can give any number of containers, each with its own name and state. You can add a command to docker run after the image name — the container then runs it instead of the image's command.

docker ps shows only running containers. All of them, stopped ones included, are listed by docker ps -a. The STATUS column shows Up and the uptime for a running container, and Exited for a stopped one, with the exit code in brackets and how long ago it stopped.

Exercise · look

Find the web container

See which images are on the machine, then list all containers, including stopped ones.

First, predict

What status will web have in the sudo docker ps -a output?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Ubuntu 24.04
Loading…