docker-machine の env 設定を削除する
docker の導入 on macOSで紹介したdocker-machineだが、docker runの--volumeオプションがうまく反映されなかったので、環境変数を削除したい
結論
code:console
% docker-machine env -u >> ~/.zshrc
% source ~/.zshrc
または
code:.zshrc
eval $(docker-machine env -u)
を追記
.zshrcの部分は使用しているシェルに合わせて適当に置き換えてください
解説
docker-machine env -uで Unset できるらしいことがヘルプに書いてあるが、実際は以下のようになり、unsetする方法コマンドを紹介してくれるだけの模様…。
code:console
docker-machine env -u
unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset DOCKER_MACHINE_NAME
# Run this command to configure your shell:
# eval $(docker-machine env -u)
ということで、これを.zshrcに追記して、sourceするのが先に示した手順
その下のコメントアウトを設定するならその下の手順
(参考)docker-machineのオプション
code:console
% docker-machine env -h
Usage: docker-machine env OPTIONS arg...
Display the commands to set up the environment for the Docker client
Description:
Argument is a machine name.
Options:
--swarm Display the Swarm config instead of the Docker daemon
--shell Force environment to be configured for a specified shell: fish, cmd, powershell, tcsh, emacs, default is auto-detect
--unset, -u Unset variables instead of setting them
--no-proxy Add machine IP to NO_PROXY environment variable
おまけ
上にたどり着く前に、色々模索していた時の残骸
code:shell
env | grep DOCKER | sed 's/=.*//'
これで、docker周りの環境変数名だけを抜き出せる
#docker
#shellscript
#sed