Install Docker on macOS

Installing Docker on macOS is straightforward with Docker Desktop. This guide covers the complete setup process for Mac users.

System Requirements

  • macOS 10.15+ (Catalina or newer)
  • At least 4GB RAM
  • Virtualization enabled in BIOS

Method 1: Docker Desktop (Recommended)

Docker Desktop provides an all-in-one solution with GUI, Docker Engine, Docker Compose, and Kubernetes support.

Download Docker Desktop

  1. Visit Docker Desktop for Mac
  2. Download the Docker Desktop installer
  3. Double-click the .dmg file
  4. Drag Docker to your Applications folder

Initial Setup

  1. Launch Docker Desktop from Applications
  2. Accept the Docker Desktop Service Terms
  3. Enter your system password when prompted
  4. Docker will start and the whale icon will appear in your menu bar

Verify Installation

Open Terminal and run:

docker --version
docker compose version
docker run hello-world

Method 2: Homebrew Installation

Install Docker Desktop via Homebrew

# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Docker Desktop
brew install --cask docker

Start Docker Desktop

open /Applications/Docker.app

Method 3: Manual Docker Engine Installation (Advanced)

For users who prefer command-line Docker without GUI:

Install Docker Engine

brew install docker docker-compose

Install Docker Machine (for older macOS versions)

brew install docker-machine

Start Docker Service

# Using Docker Machine (older method)
docker-machine create --driver virtualbox default
eval $(docker-machine env default)

# Using colima (modern alternative)
brew install colima
colima start

Docker Desktop Configuration

Resource Allocation

  1. Click Docker Desktop menu bar icon
  2. Go to Settings > Resources
  3. Adjust memory, CPU, and disk space as needed:
    • Memory: 4GB+ (recommended 8GB)
    • CPU: 2+ cores
    • Disk: 64GB+ (for image storage)

File Sharing

  1. Go to Settings > Resources > File Sharing
  2. Add your project directories
  3. This allows containers to access local files

Kubernetes (Optional)

  1. Go to Settings > Kubernetes
  2. Enable Kubernetes
  3. Wait for installation to complete

Command Line Tools

Docker Compose v2 (Plugin)

Docker Desktop includes Docker Compose as a plugin:

docker compose version

Useful Aliases

Add to your ~/.zshrc or ~/.bash_profile:

# Docker aliases
alias d='docker'
alias dc='docker compose'
alias dps='docker ps'
alias di='docker images'
alias d logs='docker logs -f'

Development Integration

VS Code Integration

Install the Docker extension from Microsoft:

  1. Open VS Code
  2. Go to Extensions
  3. Search “Docker”
  4. Install Microsoft Docker extension

IntelliJ IDEA Integration

  1. Go to File > Settings > Plugins
  2. Search and install “Docker” plugin
  3. Configure Docker connection

Common Issues and Solutions

Docker Desktop Won’t Start

# Reset to factory defaults
# Click Docker Desktop icon > Troubleshoot > Reset to factory defaults

Permission Denied Errors

# Ensure Docker Desktop is running
open /Applications/Docker.app

# Check Docker daemon
docker info

Port Conflicts

# Check what's using the port
lsof -i :8080

# Change Docker port mapping
docker run -p 8081:80 nginx

Out of Disk Space

  1. Clean unused images:
docker system prune -a
  1. Increase disk allocation in Docker Desktop Settings

Slow Performance

  1. Increase memory allocation in Docker Desktop
  2. Use .dockerignore files
  3. Mount volumes efficiently

Production Considerations

Using Docker Compose

Create docker-compose.yml:

version: '3.8'
services:
  web:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - .:/app
    environment:
      - NODE_ENV=development

Multi-Container Development

# Start all services
docker compose up -d

# View logs
docker compose logs -f

# Stop all services
docker compose down

Security Best Practices

Regular Updates

Keep Docker Desktop updated:

brew upgrade --cask docker

Image Security

# Scan images for vulnerabilities
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
  aquasec/trivy image your-image-name

Sources

For Linux installation, see our Docker Linux setup. Windows users should check our Windows Docker installation.