Skip to content

Instantly share code, notes, and snippets.

@manno
Created September 3, 2021 16:06
Show Gist options
  • Save manno/7ae647d1ef644437bc48e6b0a7cc1982 to your computer and use it in GitHub Desktop.
Save manno/7ae647d1ef644437bc48e6b0a7cc1982 to your computer and use it in GitHub Desktop.
# brew install docker multipass
# # in case docker desktop broke the symlink
# brew link docker
# # ssh key to use
# sshpub=`ls -1tr ~/.ssh/*pub | tail -1`
# cat > cloud-init.yaml <<EOF
# ssh_authorized_keys:
# - `cat "$sshpub"`
# EOF
# create and set up vm
n=primary
multipass launch --name $n --cloud-init cloud-init.yaml -m 5G -d 10G
multipass exec $n -- sudo apt update -y
multipass exec $n -- sudo apt install -y docker.io
multipass exec $n -- sudo systemctl enable --now docker
multipass exec $n -- sudo adduser ubuntu docker
# setup ssh
ip=`multipass info $n | grep IPv4 | awk '{print $2}'`
ssh-keygen -R $ip
ssh ubuntu@$ip id
# finally
echo export DOCKER_HOST=ssh://ubuntu@$ip
# test
export DOCKER_HOST=ssh://ubuntu@$ip
docker ps
# laptop crashed, instance lost, thanks multipass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment