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:
Congratulations, you just ran your first container! Here’s what just happened in detail:
-
Your command asks Docker to create and run a container based on the hello-world image.
-
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.
-
Docker created a container based on the hello-world image.
-
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.
-
The container stopped.
Here’s what you did, slightly simplified:
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.