Step-by-Step Guide: Installing Docker Desktop on Windows and macOS

Get started with Docker by installing Docker Desktop on Windows and macOS. This step-by-step guide covers prerequisites, download instructions, installation procedures, and initial verification steps for both operating systems. Learn to set up your development environment for efficient containerization.

26 views

Step-by-Step Guide: Installing Docker Desktop on Windows and macOS

Docker has revolutionized the way developers build, ship, and run applications. By containerizing applications, Docker ensures consistency across different environments, from a developer's laptop to production servers. For many, the journey into the world of containers begins with installing Docker Desktop, the easiest way to get Docker running on your personal machine.

This guide provides a comprehensive, step-by-step walkthrough for installing Docker Desktop on both Windows and macOS. We'll cover the necessary prerequisites and guide you through the initial setup to ensure a smooth and successful Docker experience right from the start. Whether you're new to Docker or looking for a refresher, this guide will equip you with the knowledge to get your development environment ready for containerized applications.

Understanding Docker Desktop

Docker Desktop is an application for Mac and Windows that makes it easy to build and share containerized applications. It bundles the Docker Engine, Docker CLI client, Docker Compose, Kubernetes, and Docker Content Trust, providing a complete development environment in a single package.

Key components included in Docker Desktop:

  • Docker Engine: The underlying daemon that runs and manages containers.
  • Docker CLI: The command-line interface used to interact with the Docker Engine.
  • Docker Compose: A tool for defining and running multi-container Docker applications.
  • Kubernetes: An open-source system for automating deployment, scaling, and management of containerized applications.

Prerequisites for Installation

Before you begin the installation process, ensure your system meets the following requirements. Meeting these prerequisites will prevent potential issues during and after installation.

For Windows:

  • Operating System: Windows 10 64-bit: Pro, Enterprise, or Education (Build 19041 or higher). Windows 11 64-bit: Pro, Enterprise, or Education (Build 22000 or higher).
  • Hardware Virtualization: Must be enabled in the BIOS. Most modern computers have this enabled by default. You can check this by opening Task Manager, going to the 'Performance' tab, and looking for 'Virtualization' under the CPU section. It should say 'Enabled'.
  • WSL 2 Installation (Recommended): For optimal performance, Docker Desktop on Windows uses the Windows Subsystem for Linux 2 (WSL 2). If it's not installed, Docker Desktop will guide you through the installation. Ensure you have WSL 2 installed by running wsl --install in an elevated PowerShell or Command Prompt. For more detailed instructions, refer to the official Microsoft WSL documentation.
  • Minimum System Resources:
    • 4 GB RAM
    • 64-bit processor with Second Level Address Translation (SLAT)
  • Note: Docker Desktop does not support Windows Server versions.

For macOS:

  • Operating System: macOS 11 (Big Sur) or newer.
  • Hardware:
    • Mac with an Apple chip (M1 or newer) or an Intel chip with 64-bit processor.
    • At least 4 GB RAM (8 GB or more recommended).
  • Browser: For downloading the application.

Installing Docker Desktop on Windows

Follow these steps to install Docker Desktop on your Windows machine:

  1. Download Docker Desktop:
    Go to the official Docker website and download the Docker Desktop installer for Windows. You can usually find it under the 'Products' > 'Docker Desktop' section.

  2. Run the Installer:
    Once the download is complete, locate the .exe file and double-click it to start the installation wizard.

  3. Configuration Options:
    During the installation, you will be presented with configuration options. Ensure that:

    • "Install required Windows components for WSL 2" is checked (if not already installed).
    • "Use WSL 2 instead of Hyper-V (recommended)" is checked.

    Docker Desktop Installation Options Windows Example image of installation options

  4. Complete Installation:
    Click 'Ok' or 'Next' to proceed. The installer will download and install the necessary components. This may take several minutes.

  5. Restart Your Computer:
    After the installation is complete, you will be prompted to close and restart your computer to finalize the setup.

  6. Launch Docker Desktop:
    After your computer restarts, Docker Desktop should launch automatically. If not, find it in your Start Menu and launch it. You may need to accept the terms and conditions on the first run.

Installing Docker Desktop on macOS

Installing Docker Desktop on macOS is straightforward. Follow these steps:

  1. Download Docker Desktop:
    Navigate to the official Docker website and download the Docker Desktop installer for Mac. You'll typically find two versions: one for Apple chip (M1, M2, etc.) and one for Intel chip.

  2. Open the Downloaded File:
    Once the download is complete, open the .dmg file.

  3. Drag to Applications:
    In the dialog box that appears, drag the Docker icon into your Applications folder. This copies Docker Desktop to your system.

  4. Launch Docker Desktop:
    Go to your Applications folder and double-click the Docker icon to launch the application. You might be prompted to grant Docker permissions.

  5. Accept Terms and Conditions:
    On the first launch, you will likely need to accept Docker's terms and conditions.

  6. Grant Privileges (if prompted):
    Docker Desktop may require elevated privileges to manage networking and other system-level functions. You will be prompted to enter your macOS user password.

Initial Configuration and Verification

Once Docker Desktop is installed and running, it's a good idea to verify the installation and perform some basic configuration.

Verifying the Installation

The easiest way to verify your installation is by running a simple Docker command in your terminal or command prompt.

  1. Open your terminal:

    • Windows: Open PowerShell or Command Prompt.
    • macOS: Open the Terminal application (Applications > Utilities > Terminal).
  2. Run the docker version command:
    Type the following command and press Enter:
    bash docker version

    If Docker is installed correctly, you should see output similar to this, displaying information about the Docker client and server:

    ```
    Client: Docker Engine - Community
    Version: 24.0.5
    API version: 1.43
    Go version: go1.19.12
    Git commit: ced0996
    Built: Fri Jul 21 20:35:45 2023
    OS/Arch: linux/amd64
    Context: default
    Experimental: true

    Server: Docker Engine - Community
    Engine:
    Version: 24.0.5
    API version: 1.43 (minimum version 1.12)
    Go version: go1.19.12
    Git commit: a61e2b4
    Built: Fri Jul 21 20:35:45 2023
    OS/Arch: linux/amd64
    Experimental: false
    ...
    ```

  3. Run a test container:
    To further confirm, try running a simple "hello-world" container:
    bash docker run hello-world

    This command downloads a small test image and runs it. If successful, you'll see a message indicating that your Docker installation appears to be working correctly.

Docker Desktop Settings

Docker Desktop provides a graphical interface to manage your Docker environment. You can access its settings by clicking the Docker whale icon in your system tray (Windows) or menu bar (macOS) and selecting 'Settings' or 'Preferences'.

Key settings to explore:

  • General: Options for starting Docker on login and using WSL 2 backend.
  • Resources: Configure CPU, memory, and disk image size allocated to Docker.
  • Docker Engine: Modify the Docker daemon configuration.
  • Kubernetes: Enable and manage a single-node Kubernetes cluster for local development.

Troubleshooting Common Issues

  • Virtualization Not Enabled: If Docker fails to start, ensure hardware virtualization is enabled in your BIOS/UEFI settings. The exact steps vary by motherboard manufacturer.
  • WSL 2 Issues (Windows): If you encounter problems with WSL 2, try running wsl --update in PowerShell as administrator. Ensure your Windows is up to date.
  • Firewall/Antivirus Interference: Sometimes, aggressive firewall or antivirus software can block Docker's network operations. Temporarily disabling them (with caution) can help diagnose if they are the cause.
  • Outdated Docker Version: Always ensure you are running the latest stable version of Docker Desktop. Check for updates within the application.

Conclusion

Installing Docker Desktop on Windows and macOS is the first crucial step towards leveraging the power of containerization for your development workflow. By following this guide, you should now have a working Docker environment ready for building, running, and managing your containerized applications. Remember to explore the Docker Desktop settings and familiarize yourself with basic Docker commands to maximize your productivity.

Now that Docker is installed, you can start pulling images from Docker Hub, building your own images, and running your applications in containers!