DEV Community

Harsh Pandhe
Harsh Pandhe

Posted on

Day 02: Docker Installation: Setting Up Docker on Various Platforms

Now that you’re familiar with what Docker is and why it’s so powerful, it’s time to dive into the practical side of things. In this article, we’ll guide you through installing Docker on various platforms, ensuring you have the tools ready to start your containerization journey.


Prerequisites

Before installing Docker, ensure the following:

  • Your system meets the minimum requirements for Docker installation.
  • You have administrative access to your machine.
  • A stable internet connection to download installation files.

Installing Docker

Below are step-by-step instructions for setting up Docker on popular platforms.

1. Installing Docker on Windows

Steps:

I. Download Docker Desktop:

II. Install Docker Desktop:

  • Run the downloaded installer.
  • Follow the on-screen instructions to complete the installation.
  • During the setup, ensure that the "Use WSL 2 instead of Hyper-V" option is selected (recommended).

III. Start Docker:

  • Open Docker Desktop and follow the initialization process.
  • Verify the installation by running:

     docker --version
    

Docker Website

2. Installing Docker on macOS

Steps:

I. Download Docker Desktop:

II. Install Docker Desktop:

  • Open the downloaded .dmg file and drag the Docker icon to your Applications folder.

III. Start Docker:

  • Launch Docker from the Applications folder.
  • Complete the onboarding process.
  • Verify the installation by running:

     docker --version
    

3. Installing Docker on Linux

Supported Distributions:

Docker supports major Linux distributions such as Ubuntu, Debian, Fedora, and CentOS.

Docker Offers Different OS

Steps for Ubuntu/Debian:

I. Update the Package Index:

   sudo apt update
Enter fullscreen mode Exit fullscreen mode

II. Install Prerequisites:

   sudo apt install apt-transport-https ca-certificates curl software-properties-common
Enter fullscreen mode Exit fullscreen mode

III. Add Docker’s Official GPG Key:

   curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Enter fullscreen mode Exit fullscreen mode

VI. Add Docker Repository:

   echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Enter fullscreen mode Exit fullscreen mode

V. Install Docker:

   sudo apt update
   sudo apt install docker-ce docker-ce-cli containerd.io
Enter fullscreen mode Exit fullscreen mode

VI. Verify Installation:

   docker --version
Enter fullscreen mode Exit fullscreen mode

Post-Installation Steps

Verify Docker Installation

To ensure Docker is installed correctly, run the following command:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Hello World

This command pulls a test image from Docker Hub and runs it in a container. If successful, you’ll see a message confirming that Docker is working.

Optional: Manage Docker as a Non-Root User

For Linux users, running Docker commands without sudo can improve convenience. Add your user to the Docker group:

sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

Log out and log back in for the changes to take effect.


Conclusion

With Docker installed on your machine, you’re ready to start working with containers. In the next article, we’ll explore Docker images and containers, diving into how to build, pull, and run them. Stay tuned!

Top comments (0)