setup docker on mac without docker desktop

2022-01-07T00:00:00.000Z

It’s for my memorandum. it’s following this blog .

setup docker on mac without docker desktopb

my env

  • intel mac
  • macOS BigSur version 11.6.1
  • using zsh

uninstall docker desktopo

please follow docker docs

setup lima

lima is Linux virtual machin on macOS.

brew install lima
limactl start
lima sh -c 'curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg'
lima sh -c 'echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null'
lima sudo apt-get update
lima sudo apt-get install -y docker-ce docker-ce-cli containerd.io
lima sudo sh -c 'echo "{\"hosts\": [\"tcp://127.0.0.1:2375\", \"unix:///var/run/docker.sock\"]}" > /etc/docker/daemon.json'
lima sudo mkdir -p /etc/systemd/system/docker.service.d/
lima sudo sh -c 'echo "[Service]\nExecStart=\nExecStart=/usr/bin/dockerd" > /etc/systemd/system/docker.service.d/override.conf'
lima sudo systemctl daemon-reload
lima sudo systemctl restart docker.service
curl -o docker.tgz https://download.docker.com/mac/static/stable/x86_64/docker-20.10.9.tgz
tar xvf docker.tgz
mv docker/docker ~/bin/docker # please move to under PATH dir.
rm docker.tgz
curl -Lo docker-compose https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-darwin-x86_64
chmod +x docker-compose
mv docker-compose ~/bin/
echo 'export DOCKER_HOST='tcp://127.0.0.1:2375' >> .zshrc
. ~/.zshrc

check

$ limactl start
$ docker version
Client:
 Version:           20.10.9
 API version:       1.41
 Go version:        go1.16.8
 Git commit:        c2ea9bc
 Built:             Mon Oct  4 16:08:54 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.12
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.12
  Git commit:       459d0df
  Built:            Mon Dec 13 11:43:41 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.5.8
  GitCommit:        1e5ef943eb76627a6d3b6de8cd1ef6537f393a71
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

$ docker run hello-world

Hello from Docker!
...

if you want to stop docker

limactl stop