DEV Community

Harsh Pandhe
Harsh Pandhe

Posted on

3

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!

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay