Last active
November 1, 2022 22:29
-
-
Save svanellewee/ed709745726a58f53c7969bcb887f78f to your computer and use it in GitHub Desktop.
start multipass docker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export DOCKER_HOST=ssh://[email protected] | |
export DOCKER_HOST=tcp://docker.local | |
multipass set client.primary-name=docker | |
function start-docker() { | |
local SSH_KEY="id_$RANDOM" | |
local PUBLIC_SSH_KEY="${SSH_KEY}.pub" | |
ssh-keygen -b 2048 -t rsa -f "$SSH_KEY" -P "" | |
ssh-add "${SSH_KEY}" | |
cat <<-EOF | tee /tmp/user-conf.yml | |
--- | |
users: | |
- name: ubuntu | |
sudo: ALL=(ALL) NOPASSWD:ALL | |
ssh-authorized-keys: | |
- $(cat ${PUBLIC_SSH_KEY}) | |
package_update: true | |
packages: | |
- docker | |
- avahi-daemon | |
- apt-transport-https | |
- ca-certificates | |
- curl | |
- gnupg | |
- lsb-release | |
write_files: # Allows us to mount docker directly without ssh magics.. | |
- path: /etc/systemd/system/docker.service.d/docker.conf | |
content: | |
| | |
[Service] | |
ExecStart= | |
ExecStart=/usr/bin/dockerd | |
- path: /etc/docker/daemon.json | |
content: | |
| | |
{ | |
"insecure-registries": [], | |
"hosts": ["unix:///var/run/docker.sock","tcp://0.0.0.0:2375"], | |
"features": { "buildkit" : true } | |
} | |
runcmd: | |
- sudo curl -fsSL https://get.docker.com | sudo bash | |
- sudo systemctl enable docker | |
- sudo systemctl enable -s HUP ssh | |
- sudo groupadd docker | |
- sudo usermod -aG docker ubuntu | |
EOF | |
multipass launch -c 2 -m 2G -d 40G -n docker 20.04 --cloud-init /tmp/user-conf.yml | |
echo "done" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
docker.conf
anddaemon.json
overrides the originalExecStart
Value so that I can specify thehosts
myself in a simpler way in json.