DEV Community

Deborah Emeni
Deborah Emeni

Posted on

Getting Started with Docker - How to install Docker and set it up correctly

Before running any docker commands, you need install Docker and ensure it’s running properly. You’ll need to do the following:

  1. Install Docker on your system
  2. Verify that Docker is running
  3. Run a test container to confirm everything is set up

Step 1: Install Docker

Go to the official Docker website and download Docker Desktop for your operating system:

Follow the steps here to download Docker or click the “Dowload Docker Desktop” button:

Download docker

Choose the version that matches your OS:

  • Windows: Install Docker Desktop for Windows (Follow the steps here)
  • Mac: Install Docker Desktop for Mac (Follow the steps here)
  • Linux: Install Docker Engine manually (Follow the steps here)

Step 2: Verify that Docker is running

After installation, Docker needs to be running before you can use it.

On Windows & Mac, open Docker Desktop and wait for it to say "Docker is running."

On Linux, start Docker manually by running:

sudo systemctl start docker
Enter fullscreen mode Exit fullscreen mode

Then, verify it’s running with:

docker info
Enter fullscreen mode Exit fullscreen mode

If Docker is running, you’ll see detailed information about your system. For example, if you run the command, you’ll see something like this in your terminal:

docker info terminal output

What you can see in the terminal output for the (docker info command) above means a few things:

  • It is running Docker version 27.5.1.
  • The Docker daemon (the background service that runs on your machine and manages Docker containers, images, networks, and volumes) is active and responding (shown by the full server information being available).
  • The Docker daemon (the background service that runs on your machine and manages Docker containers, images, networks, and volumes) is active and responding (shown by the full server information being available).
  • Docker reports 0 containers running, which is expected if you haven’t started any yet.

Now, see the screenshot below showing a Docker Desktop that shows “Engine running” in the lower left corner, confirming the Docker engine is active:

Engine running docker desktop

Step 3: Run a test container

To confirm everything works, run:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

This will:

  1. Download the hello-world container from Docker Hub
  2. Run it as a container
  3. Display a message confirming that Docker is set up correctly

Note: Docker Hub is an online repository where you can find and download container images for different software.

A Docker image is a lightweight, standalone package that contains everything needed to run a container, including the OS, system tools, and application dependencies. When you run a container, it is created from an image.

If you see output saying "Hello from Docker!", then Docker is working.

You’ll see something like this your terminal:

docker run helloworld command

Again what this command does:

When you run docker run hello-world, you’re asking Docker to:

  • download a small test image called hello-world (if it's not already on your machine)
  • create and start a container from that image
  • run a program inside the container that prints a message to confirm everything is working

Let’s go into it in more detail, okay?

Step-by-step breakdown of what happened

1. Docker checked for the image locally

The terminal above said:

Unable to find image 'hello-world:latest' locally
Enter fullscreen mode Exit fullscreen mode

That means Docker looked on your computer for the hello-world image but didn’t find it, so it had to pull it from Docker Hub.

2. Docker pulled the image from Docker Hub

latest: Pulling from library/hello-world

Pull complete

Status: Downloaded newer image for hello-world:latest
Enter fullscreen mode Exit fullscreen mode

This shows that Docker successfully downloaded the latest version of the hello-world image from Docker Hub. As I said earlier, Docker Hub is like a public library for container images.

3. Docker ran the container

Once the image was downloaded, Docker created a container and ran it. The container contains a tiny program that simply prints:

Hello from Docker!

This message shows that your installation appears to be working correctly.
Enter fullscreen mode Exit fullscreen mode

This message means Docker is installed correctly, the Docker daemon is running, and Docker can download, create, and run containers successfully.

4. Docker explains what it just did

The message continues:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

3. The Docker daemon created a new container from that image...

4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.
Enter fullscreen mode Exit fullscreen mode

This gives you insight into how Docker works behind the scenes:

  • The Docker client (you) sends a command
  • The Docker daemon (background service) does the work: pulling the image, creating the container, and running the code
  • The output of the container is sent back to your terminal

5. It gives you a next step

At the bottom, Docker suggests:

To try something more ambitious, you can run an Ubuntu container with:

docker run -it ubuntu bash
Enter fullscreen mode Exit fullscreen mode

You have now successfully installed Docker and ensured it's running correctly. Congrats!

Top comments (0)