🎓 A1Learner
🔍
0 of 50 lessons completed

Run Your First Container

Running your first container means one command: docker run hello-world. Docker pulls the image if needed, runs it, and prints its greeting.

Run hello-world

This command runs the test image in a container.

docker run hello-world

See the stopped container

The container stops after printing. It is still listed with -a.

docker ps -a --format "{{.Names}} {{.Image}}"

Example

docker run hello-world

Key points

  • docker run starts a container from an image.
  • Docker pulls the image from Docker Hub when it is not on the machine.
  • hello-world is a tiny test image that prints a greeting and stops.
  • Read the output line by line. It names each step Docker took.
  • Use docker ps -a to see the stopped container afterwards.

In this example, Docker runs the hello-world image. The output first says the image is pulled, then prints the greeting. The greeting proves Docker can pull an image, start a container, and show its output.

Note

The first run downloads the image. Later runs reuse it and start at once.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

What does docker run hello-world do first when the image is missing?