Series: Docker Tutorial

Install Docker Engine

Learn how to install Docker on Windows, Mac, and Linux systems. Our guide provides step-by-step instructions and tips for a smooth Docker installation process
E
Edtoks5:13 min read

 

Docker has become an integral part of modern software development, allowing for efficient containerization and deployment of applications. In this comprehensive guide, we will walk through the step-by-step process of installing Docker on Windows, Mac, and Linux systems. Each platform has its unique considerations, and we'll provide detailed instructions along with explanations for the commands involved.

1. Installing Docker on Windows

1.1 Prerequisites

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

  • Windows 10 64-bit: Pro, Enterprise, or Education editions with Hyper-V and Containers features enabled.
  • Virtualization must be enabled in the BIOS/UEFI settings.

1.2 Installation Steps

1.2.1 Enable Hyper-V

Ensure that Hyper-V is enabled on your Windows machine. Follow these steps:

  • Open PowerShell as an administrator.
  • Run the following command:
  • dism.exe /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL

1.2.2 Install Docker Desktop

Docker Desktop is the easiest way to install Docker on Windows. Follow these steps:

  1. Download Docker Desktop from the official Docker website: Docker Desktop for Windows.

  2. Double-click the downloaded installer to start the installation process.

  3. Follow the on-screen instructions to complete the installation.

  4. After installation, Docker Desktop starts automatically. You'll see the Docker icon in the system tray once it's running.

1.2.3 Verify Installation

Open PowerShell or a command prompt and run the following command to verify that Docker is installed correctly:

docker --version

 

This command should display the installed Docker version. 

docker run hello-world

This command downloads a test image and runs a container, confirming that your installation is working.

2. Installing Docker on macOS

2.1 Prerequisites

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

  • macOS 10.14 Mojave or later.
  • Virtualization must be enabled in the BIOS/UEFI settings.

2.2 Installation Steps

2.2.1 Install Docker Desktop for Mac

Docker Desktop for Mac provides a straightforward installation process:

  1. Download Docker Desktop for Mac from the official Docker website: Docker Desktop for Mac

  2. Open the downloaded .dmg file.

  3. Drag the Docker icon to the Applications folder to install it.

  4. Open Docker from the Applications folder.

  5. Docker Desktop starts, and you'll see the Docker icon in the menu bar once it's running.

2.2.2 Verify Installation

Open a terminal and run the following commands to verify your Docker installation:

docker --version

This command should display the installed Docker version.

docker run hello-world

This command downloads a test image and runs a container, confirming that your installation is working.

3. Installing Docker on Linux/Ubuntu

3.1 Prerequisites

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

  • A 64-bit installation.
  • A version of the Linux kernel that supports cgroups and aufs.

3.2 Installation Steps

3.2.1 Uninstall Older Versions

If you have older versions of Docker installed, uninstall them:

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

3.2.2 Install Docker Engine

Follow these steps to install Docker on Ubuntu-based systems:

  1. Update the apt package index and install required packages:

    sudo apt-get update
    sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
  2. 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
     
  3. Set up the stable Docker repository:

    echo "deb [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
    
     
  4. Install Docker Engine:

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

3.2.3 Manage Docker as a Non-Root User

By default, managing Docker requires root (sudo) access. To avoid using sudo with Docker, add your user to the docker group:

sudo usermod -aG docker $USER

Logout and log back in or restart your system for the changes to take effect.

3.2.4 Verify Installation

Run the following commands to verify your Docker installation:

docker --version 

This command should display the installed Docker version.

docker run hello-world

This command downloads a test image and runs a container, confirming that your installation is working.

4. Conclusion

Congratulations! You've successfully installed Docker on Windows, Mac, or Linux. Docker provides a powerful and consistent environment for developing, testing, and deploying applications. As you continue your journey with Docker, explore its vast ecosystem of tools, services, and container orchestration platforms to unlock the full potential of containerization in your software development workflow.