# Fix broken Docker Development on Macbook M1

- URL: https://www.heissenberger.at/en/blog/macbook-m1-docker-development/
- Language: en
- Published: 2020-11-22
- Tags: Docker, Apple, Hardware

> Why Docker for Apple M1 Hardware is broken and how to get a working environment.

## Docker is not supported on Apple M1 MacBooks and Mini

*Figure: Docker Logo*

Docker is based on `golang` and needs virtualization support.
Getting `go` to support the new architecture is not a problem and will be solved soon.

The big problem is **virtualization support** which was always a problem for docker on
windows where `Windows Home` had no support and not all Chips used for PC had the required chipsets.

Docker has [posted a blog post](https://www.docker.com/blog/apple-silicon-m1-chips-and-docker/)
which did a good explaination of all the problems which all need to be solved:

- migrate to new hypervisor framework (does not exist in public version of `Big Sur`)
- multi-architecture builds
- `golang` with native M1 support
- `Electron` with native M1 support for Docker Desktop - but works based on the info in the post

## What is the time frame for this roadmap

Looking at the links to the [roadmap](https://github.com/docker/roadmap) in the blog, you will quickly find out that **there is none**.
Based on the complexity of the project and the dependency on Apple I would **expect minimum 6 to 8 months** for this to be fixed.
The only possibility to solve this quicker would be a direct involvement of Apple which has not happened in the past.

## Intermediate solutions with a M1 MacBook Air / Pro

Move your Docker Development Environment into the Cloud:

### Docker Engine

Use any local or cloud hosted linux host and [install docker](https://hub.docker.com/search?q=&type=edition&offering=community&operating_system=linux).

Ways to access the Docker Engine:

1. `ssh` to remote host and run all command on the remote host
2. access the docker api from the local operating_system

I suggest option 2) and the usage of [`Docker Contexts`](https://www.docker.com/blog/how-to-deploy-on-remote-docker-hosts-with-docker-compose/):

1. create once context to the remote system `docker context create remote ‐‐docker "host=ssh://user@remotemachine"`
2. now you can switch the default context with `docker context use remote` or use the `--context` option e.g. `docker-compose ‐‐context remote up -d`

**Pros:**

- no dependency on any progress with the M1 Architecture
- 3 times more speed for filesystem access
- any hardware requirement is possible

**Cons:**

- breaks any work flow which depends on mounting the local MacOS filesystem into Docker (see [Fix mounting ](#))

### Docker Machine

*Figure: Docker Machine Architecture*

[Docker Machine](https://github.com/docker/machine) supports creating Docker hosts on any local Computer (Intel Architecture)
or [Cloud Provider](https://github.com/docker/docker.github.io/blob/master/machine/AVAILABLE_DRIVER_PLUGINS.md)
(Digital Ocean, AWS, KVM,...) and [more](https://github.com/machine-drivers)

**Pros:**

- no dependency on any progress with the M1 Architecture
- 3 times more speed for filesystem access
- any hardware requirement are possible

**Cons:**

- breaks any work flow which depends on mounting the local MacOS filesystem into Docker (see [Fix mounting ](#))
- official `Docker Machine` is **no longer supported** and there will be no [further Development](https://github.com/docker/machine/issues/4537)

### Cloud Container Development (Blimp)

*Figure: Blimp Logo*

[Blimp](https://blimpup.io) is a drop-in replacement for Docker Compose that enables development in the cloud.

**Pros:**

- no dependency on any progress with the M1 Architecture
- 3 times more speed for filesystem access
- some hardware requirement are possible
- **mounting local volumes** into container is built-in with synchronization

**Cons:**

- has [some restrictions](https://blimpup.io/docs/#/compose-diff) on mounting, volumne drivers, DNS
- does not support `host.docker.internal`
- lock-in with their comandline client
- you cannot choose your cloud provider

### Cloud based Development Environment

*Figure: Codespaces*

A full Development Environment in the Browser which includes VS Code, Github Actions for CI/CD and a cloud hosted virtual machine
automatical started and setup on each editor launch.

When [Github Codespaces](https://github.com/features/codespaces) will become public they will allow to run
Docker based Environments in the cloud.

**Pros:**

- any local Harware or Operating System with a reason Browser sufficiant
- 3 times more speed for filesystem access
- any hardware requirement availiable on Microsoft Azure

**Cons:**

- constant internet access required, no offline defelopment
- lock-in with Microsoft hosting

## Fix mounting local MacOS filesystem Problem

[Visual Studio Code Remote Development](https://code.visualstudio.com/docs/remote/remote-overview) allows to use
`Docker Compose` to [setup complex enviroments](https://code.visualstudio.com/docs/remote/containers-advanced) and connect with the container.

*Figure: VS Code Remote development architecture*

`VS Code` will run on MacOS and offer native M1 Power but the Terminal and files are directly edited inside Containers.
This allows to stay with existing development workflows in depend of the docker engine running on another host.

The `.devcontainer/` configuration additional add support for port forwarding which helps to establish an environment similar to
having everything local.

## My personal Roadmap to a M1 based MacBook

I am currently using a 13" MacBook Pro 2016, Intel 3.3 GHz i7 and was planning to switch to a new MacBook Pro i7/32GB which I had ordered beginning of September.
When Apple presented the new MacBooks with M1 Chip I immediately canceled the order.

My current development environment for web based application and services is based on:

- Docker Desktop for Mac
- brew (node, yarn,..)
- VirtualBox (Windows Browser Tests)

Hardware:

- 2x Samsung Monitors (1920x1200)
- HP Dockingstation G5

The only problem I have with current setup is **Speed** - some of my bigger php application eat a lot of memory and cpu.

I first thought after studying benchmarks and posts that my only problem is `VirtualBox`.
Buying a [Stick PC](https://www.amazon.com/s?k=stick+pc+acepc) solved this and gives me
a native local windows hardware for less than 90€.

But the **NO Docker support** made it clear that I **will wait for the next generation** of the MacBook Pro with more Memory and
updated version of Big Sure and Docker.

In the meantime, I will test developing in the cloud which is no option for locations without good internet access :-(

**What are your plans to develop with docker / kubernetics?**

[Write a response on Medium](https://andreasheissenberger.medium.com/macbook-m1-breaks-docker-development-14566ab6fa2e?responsesOpen=true)
