Docker

macOS Setup

Docker Desktop for Mac provides a seamless environment for running Linux containers on macOS, handling the underlying virtual machine for you.


Install Docker Desktop

  1. Go to the Docker Desktop for Mac download page.
  2. Download the correct installer for your Mac:
    • Mac with Intel chip
    • Mac with Apple silicon (M1/M2/M3)
  3. Double-click the downloaded .dmg file.
  4. Drag the Docker icon into your Applications folder.

First Run and Configuration

  1. Open Docker from your Applications folder or Spotlight.
  2. macOS may prompt you with a security warning indicating that "Docker is an app downloaded from the Internet." Click Open.
  3. Accept the Docker Subscription Service Agreement.
  4. Docker will request privileged access to install its networking components and links in /usr/local/bin. Enter your Mac password to allow this.
  5. You will see the Docker icon (a whale) in your top menu bar. When it stops animating, Docker is running and ready.

Verify Installation

Open your Terminal app (or iTerm2) and run:

bash
docker --version

You should see output similar to Docker version 24.x.x, build xxxxxxx.

Test running a container:

bash
docker run hello-world

If successful, you will see a message saying "Hello from Docker!".


Apple Silicon (M1/M2/M3) Considerations

If you are using a Mac with Apple Silicon (ARM architecture), keep in mind that Docker will default to pulling arm64 images.

Many embedded toolchains (like older versions of the ARM GCC compiler) only provide amd64 (x86_64) binaries. Docker Desktop uses Rosetta 2 to seamlessly run amd64 containers on Apple Silicon.

If a specific toolchain image fails to run or builds incorrectly, you can force Docker to use the amd64 architecture by adding the --platform flag:

bash
docker run --platform linux/amd64 -it ubuntu:20.04 bash

Accessing USB Devices (For Flashing)

Similar to Windows, Docker Desktop on macOS runs containers inside a lightweight Linux VM. This makes passing physical USB devices (like your ESP32) directly into the container difficult.

The recommended workflow for macOS is:

  1. Build your project code inside the Docker container.
  2. Flash the generated binaries from your host Mac using natively installed tools (like EIM or esptool.py).

Next Steps

Now that you have Docker running, let's look at managing environments with Docker Compose.

Previous
Ubuntu / Linux Setup