1 - Install docker
brew install docker docker-compose docker-buildx
Set the plugin folder in docker config
cat ~/.config/docker/config.json
{
"auths": {},
"currentContext": "colima",
"cliPluginsExtraDirs": [
"/opt/homebrew/lib/docker/cli-plugins"
]
}
2 - Install colima
Here we use Colima, a wrapper around Lima (Linux Machines) to ease the management of docker containers with sane performance and facilities.
colima start \
--profile default \
--activate \
--network-address \
--arch aarch64 \
--cpu 10 \
--disk 48 \
--memory 8 \
--mount ${HOME}:w \
--ssh-agent \
--vm-type vz \
--vz-rosetta \
--verbose
- adapt
--arch
,--cpu
,--disk
,--memory
with your actual machine - for arm device only
--vm-type vz
,--vz-rosetta
(need rosetta installed) --network-address
expose the public IP (if you need to deal with local domain)- the config generated is here
~/.colima/default/colima.yaml
- the log can be found here
~/.colima/default/daemon/daemon.log
3 - Export the following environment variables to your current shell
export COLIMA_VM="default"
export COLIMA_VM_SOCKET="${HOME}/.colima/${COLIMA_VM}/docker.sock"
export DOCKER_HOST="unix://${COLIMA_VM_SOCKET}"
4 - Test
docker run --rm hello-world
docker compose version