How to Install Docker: A Step-by-Step Guide

Shubham KumarShubham Kumar
3 min read

Docker is an open-source platform that automates the deployment, scaling, and management of applications inside lightweight containers. This guide will help you install Docker on Windows, macOS, and Linux.

1. Installing Docker on Windows

Step 1: Download Docker Desktop for Windows

  1. Visit this https://docs.docker.com/engine/install/

  2. Click on the Download for Windows button to download the installer.

Step 2: Install Docker Desktop

  1. Run the downloaded installer.

  2. Follow the installation instructions. Ensure you select the option to install required dependencies like WSL 2 (Windows Subsystem for Linux 2).

Step 3: Start Docker Desktop

  1. After installation, start Docker Desktop from the Start menu.

  2. Wait for Docker to start and complete the setup process.

Step 4: Verify Installation

Open a Command Prompt or PowerShell window and run:

You should see the Docker version information.

docker --version

2. Installing Docker on macOS

Step 1: Download Docker Desktop for Mac

  1. Visit the Docker Desktop for Mac download page.

  2. Click on the Download for Mac button to download the installer.

Step 2: Install Docker Desktop

  1. Open the downloaded .dmg file.

  2. Drag the Docker icon to the Applications folder.

Step 3: Start Docker Desktop

  1. Open Docker from the Applications folder.

  2. Wait for Docker to start and complete the setup process.

Step 4: Verify Installation

Open a terminal window and run:

docker --version

You should see the Docker version information.

3. Installing Docker on Linux

Step 1: Update Your Package Manager

Open a terminal window and run:

sudo apt-get update

Step 2: Install Required Packages

Run the following command to install the necessary packages:

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

Step 3: Add Docker’s Official GPG Key

Run:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Step 4: Add the Docker APT Repository

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Step 5: Update the Package Database

sudo apt-get update

Step 6: Install Docker

sudo apt-get install docker-ce

Step 7: Start and Enable Docker

sudo systemctl start docker
sudo systemctl enable docker

Step 8: Verify Installation

Run:

docker --version

You should see the Docker version information.

Post-Installation Steps (Optional)

Manage Docker as a Non-Root User

To run Docker commands without sudo, follow these steps:

  1. Create a Docker group:

     sudo groupadd docker
    
  2. Add your user to the Docker group:

     sudo usermod -aG docker $USER
    
  3. Log out and log back in to apply the changes.

Test Docker Installation

Run the following command to test Docker:

docker run hello-world

You should see a message indicating that Docker is working correctly.

1
Subscribe to my newsletter

Read articles from Shubham Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shubham Kumar
Shubham Kumar