{"id":19853860,"url":"https://github.com/magnetikonline/macos-multipass-docker","last_synced_at":"2025-05-02T01:30:23.211Z","repository":{"id":47079346,"uuid":"513030020","full_name":"magnetikonline/macos-multipass-docker","owner":"magnetikonline","description":"Step by step guide for installing Docker under macOS via Canonical's Multipass.","archived":false,"fork":false,"pushed_at":"2024-05-15T03:44:12.000Z","size":20,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-05-15T20:46:20.168Z","etag":null,"topics":["docker","macos","multipass","ubuntu","virtualization"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magnetikonline.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-12T06:46:24.000Z","updated_at":"2024-05-30T04:12:54.011Z","dependencies_parsed_at":"2023-01-18T08:15:56.647Z","dependency_job_id":"825ab0d9-490e-4181-a13e-cf6ee7303373","html_url":"https://github.com/magnetikonline/macos-multipass-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Fmacos-multipass-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Fmacos-multipass-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Fmacos-multipass-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetikonline%2Fmacos-multipass-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magnetikonline","download_url":"https://codeload.github.com/magnetikonline/macos-multipass-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251969226,"owners_count":21673178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","macos","multipass","ubuntu","virtualization"],"created_at":"2024-11-12T14:07:52.721Z","updated_at":"2025-05-02T01:30:22.962Z","avatar_url":"https://github.com/magnetikonline.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# macOS Multipass Docker\n\nStep by step notes for installing Docker under macOS via Canonical's [Multipass](https://multipass.run/).\n\n- [What this provides](#what-this-provides)\n- [Installation](#installation)\n- [Tips](#tips)\n\t- [Disable primary instance](#disable-primary-instance)\n\t- [Restarting `multipassd`](#restarting-multipassd)\n- [Reference](#reference)\n\n## What this provides\n\n- Docker Engine (daemon).\n- `docker` CLI tool within the guest VM (_technically_ not needed, but handy if working inside VM).\n- Installed `docker` and `docker-compose` CLI tools (with Bash completion) on the macOS _host_.\n\n## Installation\n\nInstall [Multipass for macOS](https://multipass.run/docs/installing-on-macos) (obviously).\n\nNext, launch a new Multipass virtual machine.\n\n\u003e [!NOTE]\n\u003e Setting desired Multipass virtual machine name in `MACHINE_NAME` environment variable, used in all following command examples.\n\n```sh\n$ MACHINE_NAME=\"my-docker\"\n$ PATH_TO_PROJECTS=\"/path/to/projects\"\n\n$ multipass launch \\\n  --cloud-init ./cloud-init-docker.yaml \\\n  --name $MACHINE_NAME \\\n    22.04\n\n$ multipass stop $MACHINE_NAME\n$ multipass mount --type native \\\n  $PATH_TO_PROJECTS $MACHINE_NAME\n\n$ multipass start $MACHINE_NAME\n$ multipass info $MACHINE_NAME\n\n# Name:           MACHINE_NAME\n# State:          Running\n# IPv4:           --\n\n# Release:        Ubuntu 22.04.3 LTS\n# Image hash:     9256911742f0 (Ubuntu 22.04 LTS)\n# CPU(s):         --\n# Load:           --\n# Disk usage:     --\n# Memory usage:   --\n# Mounts:         /path/to/projects =\u003e /path/to/projects\n```\n\nBreaking this down:\n\n- Create new virtual machine using Ubuntu `22.04`.\n- Configure VM using `cloud-init-docker.yaml` - which will install and configure Docker dependencies.\n- Stop the instance in order to create a mount to (`path/to/projects`) within the VM _guest_ back to the macOS _host_. This is important for `Dockerfile` operations such as [`ADD`](https://docs.docker.com/engine/reference/builder/#add) - ensuring Docker Engine within the VM guest can successfully map files stored within the macOS host filesystem.\n\t- **Note:** using `multipass mount --type native` to create a native QEMU host mount, rather than the (slower) default of [SSHFS](https://github.com/libfuse/sshfs).\n\nOverview of tasks performed by [`cloud-init-docker.yaml`](cloud-init-docker.yaml):\n\n- The `avahi-daemon` provides a well-known hostname to the Multipass VM via mDNS/Bonjour from the host (e.g. your macOS).\n- A series of `runcmd` commands to install required Docker Engine packages.\n- An addition of a `/etc/systemd/system/docker.service.d/httpapi.conf` systemd unit drop-in, which starts the `/usr/bin/dockerd` daemon with the HTTP API listening on all networks.\n\nNext, install `docker` and `docker-compose` CLI tools to the macOS _host_ via [`cli-install.sh`](cli-install.sh).\n\n**Note:** script requires [`jq`](https://jqlang.github.io/jq/) to be installed:\n\n```sh\n$ ./cli-install.sh\n\n# Docker version 24.0.7, build afdd53b\n# Docker Compose version v2.23.0\n```\n\nFinally, configure a `DOCKER_HOST` environment variable, allowing the `docker` CLI to locate Docker Engine running within the Multipass Ubuntu VM:\n\n```sh\n# first, ping VM to confirm it can be found from host\n$ dns-sd -Gv4 \"$MACHINE_NAME.local\"\n\n$ export DOCKER_HOST=\"tcp://$MACHINE_NAME.local:2375\"\n$ docker version\n\n# Client:\n#  Version:           24.0.7\n#  API version:       1.43\n#  etc.\n#\n# Server: Docker Engine - Community\n#  Engine:\n#   Version:          24.0.7\n#   API version:      1.43 (minimum version 1.12)\n#  etc.\n```\n\nOnce proven working, `DOCKER_HOST` can be added to Dotfiles / `~/.bash_profile` / etc.\n\nDone!\n\n## Tips\n\n### Disable primary instance\n\nMultipass has the concept of a [primary instance](https://multipass.run/docs/primary-instance), which is automatically used for commands such as `start` and `shell`. This behaviour can be somewhat _undesirable_ - where it is preferred to use defined machine names against all `multipass` commands.\n\nLuckily the primary instance mode can be disabled by setting an empty [`client.primary-name`](https://multipass.run/docs/primary-name) value:\n\n```sh\n$ multipass set client.primary-name=\n```\n\nthe enablement of this mode can now be confirmed:\n\n```sh\n$ multipass start\nName argument or --all is required\nNote: the primary instance is disabled.\n\n$ multipass shell\nThe primary instance is disabled, please provide an instance name.\n```\n\n### Restarting `multipassd`\n\nIf the Multipass service ever falls away, such as with the following message:\n\n```sh\n$ multipass list\nlist failed: cannot connect to the multipass socket\n```\n\nit can be restarted with the following commands:\n\n```sh\n$ sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist\n$ sudo launchctl load -w /Library/LaunchDaemons/com.canonical.multipassd.plist\n```\n\n## Reference\n\n- https://multipass.run/docs/installing-on-macos\n- https://ubuntu.com/blog/using-cloud-init-with-multipass\n- https://docs.docker.com/engine/install/ubuntu/\n- https://cloudinit.readthedocs.io/en/latest/reference/examples.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnetikonline%2Fmacos-multipass-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagnetikonline%2Fmacos-multipass-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnetikonline%2Fmacos-multipass-docker/lists"}