This script will install Docker via Multipass from scratch on MacOS.
Visual Studio Code is not needed for the install, but needed to make use of it.
The script should need absolutely nothing to run from a fresh install. However you will need git to download it in the first place, so open a terminal and enter:
xcode-select --install./install.shEnter your password when prompted.
Now just clone a repository containing a devcontainer configuration and select
Reopen in Container to open it in the Docker VM.
When initially running the installer script, make sure you cloned to somewhere
other than a protected MacOS directory (such as Desktop). Otherwise you may
get mounting issues where Docker complains that the current directory doesn't
exist.
Likewise, if you're cloning to a protected directory (e.g. under Documents)
then you may find that your containers fail to mount the directory. Either move
your files to a non-protected path or enable full disk access for multipassd
in your MacOS System Settings under Privacy & Security -> Full Disk Access.
If you get errors about docker-credential-osxkeychain not existing, either
install the binary or remove the credsStore line from ~/.docker/config.json
(which was probably put there by Rancher Desktop).
If the Docker VM ever gets into a state where it won't launch, then delete it and launch it again. This means you'll need to re-add keys (and remove the old ones from your keystore) and re-mount your home directory. A helper script is supplied to do this for you:
./rebuild.shYou can do this by setting the values in Multipass:
./resize.shPrevious versions of the installer mounted the whole of $HOME into the
container. This isn't strictly necessary, and you can get away with just
mounting the Developer directory (the recommended directory for keeping code
in MacOS - create it and it gets a nice icon and everything).
You can use the provider helper script to update your mounts like so:
./remount.shYou can. First install XQuartz and log out and in
again. Then open XQuartz (in /Applications/Utilities) and in Settings,
disable authentication and enable network connections. You can now use xhost
to allow connections to the XQuartz server from the Multipass VM and use -e
to set DISPLAY properly to connect back to the host. See the provided
x11.sh for an example.
- Add a test suite.
- Test / ask for existing SSH keys.
- Add parameters to helper scripts.
- Test for the script being run from
~/Desktop,~/Documentsor~/Downloadsand error out as these are protected. - Test for
docker-credential-osxkeychainand fix. - Improve pre-commit config.
(C) Qodea 2024
MIT License, see LICENSE for details.