0
0
DockerHow-ToBeginner · 3 min read

How to Install Docker on Mac: Step-by-Step Guide

To install Docker on a Mac, download Docker Desktop for Mac from the official Docker website, then open the downloaded file and follow the installation prompts. After installation, launch Docker Desktop and verify it is running by opening a terminal and typing docker --version.
📐

Syntax

Installing Docker on Mac involves downloading the Docker Desktop installer and running it. The main commands you will use after installation are:

  • docker --version: Checks Docker version to confirm installation.
  • docker run hello-world: Runs a test container to verify Docker works.
bash
docker --version
docker run hello-world
Output
Docker version 24.0.2, build 123abc Hello from Docker! This message shows Docker is installed correctly.
💻

Example

This example shows how to check if Docker is installed and running correctly on your Mac after installation.

bash
docker --version
docker run hello-world
Output
Docker version 24.0.2, build 123abc Hello from Docker! This message shows Docker is installed correctly.
⚠️

Common Pitfalls

Common mistakes when installing Docker on Mac include:

  • Not having the required macOS version (must be macOS 11 or newer).
  • Not enabling virtualization in system settings.
  • Trying to run Docker commands before Docker Desktop is fully started.
  • Using an outdated Docker Desktop installer.

Always download the latest Docker Desktop from the official site and ensure your Mac meets the system requirements.

bash
Wrong: Trying to run docker commands before starting Docker Desktop
$ docker run hello-world
Error: Cannot connect to the Docker daemon.

Right: Start Docker Desktop first, then run commands
$ open -a Docker
$ docker run hello-world
Hello from Docker! This message shows Docker is installed correctly.
📊

Quick Reference

Summary tips for installing Docker on Mac:

  • Download Docker Desktop for Mac from docker.com.
  • Ensure macOS 11 (Big Sur) or later is installed.
  • Run the installer and follow prompts.
  • Launch Docker Desktop and wait for it to start.
  • Verify installation with docker --version and docker run hello-world.

Key Takeaways

Download Docker Desktop for Mac from the official Docker website.
Ensure your Mac runs macOS 11 or newer before installing.
Start Docker Desktop before running Docker commands in the terminal.
Verify installation by running 'docker --version' and 'docker run hello-world'.
Keep Docker Desktop updated to avoid compatibility issues.