Docker: Image and Container

Build and Run Your First Container

Getting started with Docker might seem complex at first, but it all begins with simple concepts. One of the most important is understanding what Docker images are and how to use them to create containers. In this article, we walk through the process of pulling your first image from Docker Hub and launching a container from it, using a very popular example.

First Docker Image

Docker Hub is a public repository that contains a wide range of Docker images, from simple tools to complex applications. You can begin by downloading a basic image to understand how Docker works. For learning purposes, pull the hello-world image, which is designed to demonstrate Docker's core functionality. To start, execute the docker pull command in your terminal (CMD or PowerShell), passing the image name as an argument:

docker pull hello-world

Understanding Output Messages

Running the command starts downloading the image from Docker Hub. You'll see the following messages:

First Docker Container

With the image pulled, you can now create a running container from it. Use the following command:

docker run hello-world

Running this command launches a container from the hello-world image. Here's what happens:

Container Status

Notably, the hello-world container shuts down automatically after displaying the output. Its status is shown as Exited.

Keep in mind, containers behave differently depending on the image. For example, a container based on an HTTP server image will continue running until manually stopped by the user—in that case, the container’s will stay active.