Skip to content

Instantly share code, notes, and snippets.

@pahud
Last active April 8, 2024 14:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pahud/1465b24406571096ff797727d4b4e456 to your computer and use it in GitHub Desktop.
Save pahud/1465b24406571096ff797727d4b4e456 to your computer and use it in GitHub Desktop.
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