Difficulty: Beginner
Estimated Time: 10 minutes


  • Put Docker concepts intro practice.
  • Learn basic commands to manage Docker containers.
  • Build customized images using a Dockerfile.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Introduction to Containers: Lab 01

Step 1 of 3

Hello World!

Run containers

The docker run command can be used to create a runtime instance of an image (i.e. container).

$ docker run --help

Usage:    docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

All containers are executed with a command. This command may be the default one defined by the image if the user does not specify any.

Let's run the hello-world image with the default command and no options:

docker run hello-world

View containers

To list the containers that currently exist in our host we use docker ps.

$ docker ps --help

Usage:    docker ps [OPTIONS]

List containers

docker ps -a

The -a option shows all containers, including those that are stopped, which is the case with the previous hello-world container.

Remove containers

How can we remove the hello-world container that is currently stopped? By using docker rm.

$ docker rm --help

Usage:    docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers

We need to get the container ID or name from docker ps and then run this command:

docker rm <container_id_or_name>