cd ~

Installing Docker and k3d on Apple M1

Note: This post is out of date. I’d suggest instead using Rancher Desktop

Note: These steps were performed on an M1 Macbook Air

Some may want to install docker or a local k8s instance on their Mac. Here’s a quick guide to get things up and running with k3d.

You’ll need to install Docker desktop, Homebrew, configure homebrew, k3d, and configure your k8s cluster.

  1. Download and install the Docker technical preview for Apple M1 Macs (In the future, once Docker has an official release, use that instead. I’ll try to remember to update this…).
  2. Install Homebrew
    # I suggest running the following in ~/
    mkdir homebrew \
      && curl -L \
      | tar xz --strip 1 -C homebrew
  3. Configure Hombrew to be accessable in your path. Assuming you’re using ZSH (default shell for macOS), add the following lines to your .zshrc:
    # Assuming you extracted Homebrew to ~/homebrew
    # Replace $USER with your username
    export PATH=$PATH:/Users/$USER/homebrew/bin
    export MANPATH=$MANPATH:/Users/$USER/.brew/manpages
  4. Source your updated ~/.zshrc: . ~/.zshrc
  5. Ensure Docker desktop is running. If not, launch it, then proceed to install k3d. To install k3d, run: brew install k3d
  6. Configure your cluster:
    # Replace my cluster with your prefered cluster name
    % k3d cluster create mycluster
  7. Verify k8s is now up and running:
    % kubectl get nodes
    NAME               STATUS   ROLES                  AGE   VERSION
    k3d-k8s-server-0   Ready    control-plane,master   13d   v1.20.2+k3d1
  8. Verify containers are up in docker:
    % docker ps
    CONTAINER ID   IMAGE                      COMMAND                  CREATED       STATUS       PORTS                             NAMES
    6539623fa5f2   rancher/k3d-proxy:v4.0.0   "/bin/sh -c nginx-pr…"   13 days ago   Up 13 days   80/tcp,>6443/tcp   k3d-k8s-serverlb
    1bb6ad9d0702   rancher/k3s:latest         "/bin/k3s server --t…"   13 days ago   Up 13 days                                     k3d-k8s-server-0