Do-It-Yourself: Run a Container

In this lesson, you will learn how to run a container based on the already created hello-world image.

Note: The commands used in this course will be the same regardless of if you are using a Windows, Linux, or Mac system.

Run the above mentioned command in the given terminal:

Terminal 1
Terminal

Click to Connect...

Congratulations, you just ran your first container! Here’s what just happened in detail:

  1. Your command asks Docker to create and run a container based on the hello-world image.

  2. Since the hello-world image wasn’t already present on your disk, Docker downloaded it from a default registry, the Docker Hub. More about that later.

  3. Docker created a container based on the hello-world image.

  4. The hello-world image states that, when started, it should output some text to the console, so this is the text you see as the container is running.

  5. The container stopped.

Here’s what you did, slightly simplified:

svg viewer
Running a container

If you run the same command again, you’ll see that all the above steps are being repeated except for step 2; this is because the image does not need to be downloaded as it is already present on your machine from the first time you ran the command. This is a simple optimization, but you’ll see later that Docker optimizes many more steps. As such, Docker makes scarce use of a machine’s resources.


In the next lesson, you will be introduced to some Docker commands.

Quiz
Container Management Commands
Mark as Completed
Report an Issue