Linux Labs

Containers: Docker and compose / Stage 1 of 11

Image, container and process

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 6 · on a machine · 5 min

The web server started and vanished

What you will learn

  • Tell an image from a container and find a stopped container in docker ps -a.
  • Explain a container's status and exit code through its main process and read docker logs.
  • Start a container that keeps running and run commands inside it.

A colleague needs a web server in a Docker container on port 8080, for testing. The busybox image with the httpd server is already on the machine. Docker here is available to root only, so the docker commands go through sudo.

Start the server with the command on the card and look at the list of containers. "Start" prepares the machine.

Exercise · look

Start the web server

Start the web server in the web container with the command on the card, then look at the list of containers.

First, predict

What will sudo docker ps show after the server is started?

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
Check yourself 1 question

docker run printed a long string, yet docker ps does not list web. Which of these is true?

  • docker ps also ran with sudo, and Docker's containers are shared across the machine: a running web would be listed.

  • Docker reports a refusal with a docker: Error response from daemon: … line. The long string of digits and letters is the ID of the created container.

  • Without --rm Docker does not delete a container: the stopped web is still on the machine, and sudo docker ps -a shows it.

The web container was created, but it is not in the list of running ones.

Ubuntu 24.04
Loading…