Installing Docker: A Step-by-Step Guide

Introduction

Docker has revolutionized the way we build, ship, and run applications by using containerization. Before diving into hands-on Docker usage, the first step is installing Docker on your system. This guide provides a step-by-step installation process for Windows, macOS, and Linux.

Installing Docker A Step by Step Guide
Installing Docker A Step by Step Guide

1. Prerequisites

Before installing Docker, ensure that your system meets the following requirements:

Windows

  • Windows 10 (Pro, Enterprise, or Education) or Windows 11 with WSL 2 enabled
  • 64-bit processor with hardware virtualization enabled
  • Minimum 4GB RAM

macOS

  • macOS 11 (Big Sur) or later
  • Apple Silicon (M1/M2) or Intel processor

Linux

  • A 64-bit distribution with kernel version 3.10+
  • Root/sudo privileges

2. Installing Docker on Windows

Step 1: Download Docker Desktop

Step 2: Install Docker Desktop

  • Run the downloaded installer
  • Select the option to Use WSL 2 instead of Hyper-V (Recommended)
  • Follow the installation wizard

Step 3: Start Docker

  • After installation, launch Docker Desktop
  • Open a command prompt (PowerShell or CMD) and verify using: docker --version

Step 4: Verify Installation

Run the following command to check if Docker is working:

docker run hello-world

If the installation is successful, you will see a message confirming that your Docker container ran successfully.


3. Installing Docker on macOS

Step 1: Download Docker Desktop

Step 2: Install Docker

  • Open the .dmg file and drag the Docker.app to the Applications folder
  • Launch Docker.app

Step 3: Verify Installation

Open Terminal and check the installation:

docker --version
docker run hello-world

4. Installing Docker on Linux

Step 1: Uninstall Old Versions (If Any)

sudo apt-get remove docker docker-engine docker.io containerd runc

Step 2: Install Dependencies

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release

Step 3: Add Docker Repository

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
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

Step 4: Install Docker

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Step 5: Start and Verify Docker

sudo systemctl start docker
sudo systemctl enable docker
docker --version
docker run hello-world

5. Post-Installation Steps (Optional but Recommended)

Allow Running Docker Without Sudo (Linux Only)

By default, Docker requires root privileges. To run it as a normal user:

sudo usermod -aG docker $USER
newgrp docker

Enable Docker to Start on Boot (Linux Only)

sudo systemctl enable docker

6. Troubleshooting Installation Issues

Windows

  • If Docker fails to start, ensure WSL 2 is enabled: wsl --set-default-version 2
  • Check virtualization settings in BIOS

macOS

  • If using Apple Silicon, ensure you download the correct M1/M2 build

Linux

  • If you get permission errors, ensure you added your user to the docker group
  • Restart the system and try running Docker again

7. Conclusion

You have successfully installed Docker on your system! You can now start exploring Docker commands, creating containers, and building images. In the next article, we will dive deeper into Docker Architecture and how Docker works internally.

Leave a Reply

Your email address will not be published. Required fields are marked *

About Us

At IOCoding, we don’t just develop software; we partner with our clients to create solutions that drive success and forward-thinking. We are dedicated to the continuous improvement of our processes and the expansion of our technological capabilities.

Services

Most Recent Posts

  • All Post
  • Android Apps
  • Angular
  • Back End Development
  • Blog
  • DevOps
  • Docker
  • Educational Apps
  • Front End Development
  • Full Stack Development
  • IOCoding
  • Laravel
  • LINUX
  • MERN STACK
  • Node.js
  • PHP
  • Programming Education
  • React.js
  • Technology
  • Web Development

Company Info

Let us guide your project from an initial idea to a fully-realized implementation.

Category

Transform Your Business with Cutting-Edge Software Solutions

© 2024 Created By IOCoding