EDIT: There is now a Docker technical preview for M1 Macs. I checked it out, and it’s way more useful than this guide!
This guide is for you if you jumped on the Apple Silicon bandwagon and bought yourself a fancy new M1 Mac, but you need Docker from time to time.
It describes how I use an old Intel Mac as Docker host that runs all the Docker commands from my M1 MacBook Air. (You can use any remote Docker host for this, but for my setup an old Mac was more convenient.)
M1 (Apple Silicon) Mac: On your M1 Mac you should only install the Docker client. Since the Docker runtime won’t work on it (yet). Head over to the official Docker documentation if you haven’t go the client yet: https://docs.docker.com/engine/install/binaries/#install-client-binaries-on-macos
Intel Mac: On the Intel Mac you can follow the usual Docker installation guide: https://docs.docker.com/docker-for-mac/install/. In short: Download and follow the installation instructions in the
Enable SSH access on the old Mac
First you need to enable SSH. To do so, open System Preferences and go to Sharing.
Check the checkbox next to Remote Login to enable SSH.
In the same window I also set the computer name to something simple: e.g.
mbp. That way I can easily access the machine on my local networking using:
ssh firstname.lastname@example.org. Or
http://mbp.local/ for Docker services.
In order to do passwordless login between the two Macs, you have to copy your public key to the old Mac.
First you have to generate a new key:
Just hit enter to autofill all the inputs.
Now copy the public key to the other Mac:
cat ~/.ssh/id_dsa.pub | ssh email@example.com 'cat >> ~/.ssh/authorized_keys'
This one time you will have to input your password manually.
If this step was successful, you can now SSH into the machine without entering your password. Try it out like this:
ℹ️ Checkout this guide if you need for info: https://osxdaily.com/2012/05/25/how-to-set-up-a-password-less-ssh-login/
Enabling SSH Environments for Docker context
To allow Docker context to find the
docker command on the remote machine, you have to configure the
$PATH of the SSH sessions:
/etc/ssh/sshd_config file on the old Mac.
#PermitUserEnvironment no line and change it to
Then restart SSH by unchecking and checking the checkbox next to Remote Login in System Preferences, Sharing.
Then create a new file
~/.ssh/environment with the following content:
ℹ️ Checkout this Github issue for more info: https://github.com/docker/for-mac/issues/4382#issuecomment-603031242
Using the Docker environment from the Intel Mac on your new M1 Mac
Last thing to do is configuring our Docker command on the M1 Mac to use the old Intel Mac. For this, we use Docker context.
First you have to create a new context:
docker context create my-old-mac --docker "host=ssh://firstname.lastname@example.org"
Then you can activate it using:
docker context use my-old-mac
Now you should be able to run a test container on your M1 Mac, which is actually run on your old Intel Mac behind the scenes:
docker run hello-world
Don’t forget that if you run webservices with Docker on the old Mac, that you can’t access them via
localhost, but that you have to use the hostname of the Mac where Docker is running:
It isn’t rocket science to run Docker on your old Mac, but it’s not the most pratical solution.
So let’s hope that the Apple Sillicon Macs get Docker support soon!