How To Install Docker on Windows? A Step-by-Step Guide

3 min read 1 year ago
Published on Aug 04, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

In this tutorial, you will learn how to install Docker on Windows 11. Docker is a powerful platform for building, shipping, and running containerized applications. This guide will take you through the steps needed to download and install Docker, configure its settings, and run your first Docker container. Whether you are a beginner or an experienced developer, this tutorial will help you get started with Docker on Windows.

Step 1: Check System Requirements

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

  • Windows 11 (64-bit) with:
    • Home, Pro, Enterprise, or Education version 21 H2 or higher
  • Enabled features:
    • WSL 2 (Windows Subsystem for Linux)
    • Hyper-V
  • Minimum hardware:
    • 64-bit processor
    • 4GB RAM

You can find detailed requirements on the Docker official documentation.

Step 2: Enable WSL 2 and Hyper-V

  1. Open the search bar and type "Turn Windows features on or off."
  2. In the list, find and enable:
    • Hyper-V
    • Windows Subsystem for Linux
  3. Click OK and allow Windows to search for required files.
  4. Restart your computer to apply the changes.

Step 3: Create a Docker Account

  1. Go to the Docker website.
  2. Click on "Get Started" to create a new account.
  3. Fill in the required information (username, email, password) and complete the signup process.

Step 4: Download Docker Desktop

  1. After signing in, locate and click the "Download Docker Desktop" button on the main page.
  2. Wait for the approximately 625 MB file to download.

Step 5: Install Docker Desktop

  1. Locate the downloaded file (Docker Desktop Installer) and double-click to run it.
  2. When prompted, click "Yes" to allow the app to make changes to your device.
  3. In the installation window, select:
    • Use WSL 2 instead of Hyper-V (recommended)
    • Add shortcut to desktop (if desired)
  4. Click OK and wait for the installation to complete.
  5. Once finished, restart your computer to complete the installation.

Step 6: Verify Docker Installation

  1. After restarting, open Command Prompt (search for "CMD").
  2. Check Docker version by entering:
    docker version
    
  3. If Docker is installed correctly, you will see the version information displayed.

Step 7: Run Your First Docker Commands

  1. To check for Docker images, enter:
    docker images
    
    Initially, this may return no images since it's a fresh installation.
  2. To search for specific images (e.g., MySQL), use:
    docker search mysql
    

Step 8: Troubleshooting Docker Startup Issues

If Docker does not start:

  1. Ensure WSL 2 is enabled.
  2. Follow these steps:
    • Open PowerShell as an administrator.
    • Run the following commands:
      wsl --set-default-version 2
      
    • Download and install the WSL Linux kernel update package from the Microsoft website.
    • Restart your computer and try launching Docker again.

Conclusion

You have successfully installed Docker on Windows 11 and learned how to verify its installation. Now you can explore containerization further by creating and running your own Docker containers. For further learning, consider experimenting with different Docker images and commands. If you encounter issues, refer back to the troubleshooting steps or the Docker documentation for guidance. Happy Dockering!