Docker Desktop for Mac のタグ補完(Shell Completion)


いちいち tag をコピペしたりがめんどくさかったり、オプションを覚えてられない。 Docker Desktop for Mac の場合に、毎回忘れてしまうのでメモを書いておく

Install shell completion

Docker Desktop for Mac comes with scripts to enable completion for the docker, docker-machine, and docker-compose commands. The completion scripts may be found inside Docker.app, in the Contents/Resources/etc/ directory and can be installed both in Bash and Zsh.

$ ls /Applications/Docker.app/Contents/Resources/etc/
docker-compose.bash-completion  docker-compose.zsh-completion   docker-machine.bash-completion  docker-machine.zsh-completion   docker.bash-completion      docker.fish-completion      docker.zsh-completion

docker に関しては bashzsh 以外に fish もある。

$ ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion $(brew --prefix)/etc/bash_completion.d/docker
$ ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-machine
$ ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-compose

コマンドやオプションももちろんイメージもタグ補完が聞くので便利