Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remote Docker Host for M1 laptop
  1. Open a new Amazon Linux 2 EC2(amd64) on AWS. Make it spot instance if you prefer.

ssh ec2-user@<EC2_IP> into the EC2 instance:

# install and start docker
$ sudo yum install -y docker
$ sudo service docker start
# add `ec2-user` into the `docker` group
$ sudo usermod -a -G docker ec2-user
# run newgrp as `ec2-user` to make it effective
$ newgrp docker
  1. OK now in any IDE or terminal of your Macbook M1 laptop:

Make sure you can ssh into the machine with public key auth

ssh ec2-user@<EC2_IP>

OK export the DOCKER_HOST env var

export DOCKER_HOST=ssh://ec2-user@<EC2_IP> 

Run docker ps again

docker ps

Now your docker host is running on the EC2 now. Enjoy your daily development in your favorite IDE on M1.

DONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment