Skip to main content

docker on macOS

0x01 install

nerdctl + colima + containerd

0x02 completion & alias

nerdctl completion zsh > $ZSH/custom/nerdctl.zsh

.zshrc

alias docker='nerdctl'
# complete -o default -F __start_nerdctl docker ### 貌似不需要

not working

https://github.com/containerd/nerdctl/blob/main/docs/command-reference.md#nerd_face-nerdctl-completion-zsh

nerdctl completion zsh > $(brew --prefix)/share/zsh/site-functions/_nerdctl

0x03 proxy

https://github.com/abiosoft/colima/issues/294#issuecomment-1131440640

Note: this assumes Colima v0.4.0 or newer.

  1. SSH into the VM colima ssh

  2. Edit docker init script sudo vi /etc/init.d/docker. You can install other editors e.g. sudo apk install vim nano.

  3. Append with the following

set -o allexport
if [ -f /etc/environment ]; then source /etc/environment; fi
set +o allexport

Stop Colima colima stop

Set the environment variable in the Colima config. colima start --edit or edit $HOME/.colima/default/colima.yaml

env:
HTTP_PROXY: http://proxy.example.com:80
HTTPS_PROXY: http://proxy.example.com:443
NO_PROXY: localhost,127.0.0.1,docker-registry.example.com,.corp

Start Colima colima start