Difficulty: Beginner
Estimated Time: 10 minutes

Objectives

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

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>
This tab will not be visible to users and provides only information to help authors when creating content.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]