Mik*_*der 50 macos automation docker docker-toolbox
我试图在Mac上自动设置开发人员环境.部分设置是安装Docker Toolbox.我无法通过命令行找到有关如何执行此操作的任何文档.如何自动执行此安装(必须通过命令行触发)?
更新:正如丹尼斯的赞扬所指出的那样
现在存在Docker for Mac,它是Docker Toolbox的替代品.你可以通过自制的桶来获得它:
brew cask install docker
Mik*_*der 91
我发现Docker Toolbox可以通过brew/cask获得
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Cask
brew install caskroom/cask/brew-cask
# Install docker toolbox
brew cask install docker-toolbox
Run Code Online (Sandbox Code Playgroud)
安装Docker Toolbox后,您可以使用Docker Machine入门指南设置docker环境.
# create the docker machine
docker-machine create --driver "virtualbox" myBoxName
# start the docker machine
docker-machine start myBoxName
# this command allows the docker commands to be used in the terminal
eval "$(docker-machine env myBoxName)"
# at this point can run any "docker" or "docker-compose" commands you want
docker-compose up
Run Code Online (Sandbox Code Playgroud)
在此过程结束时,添加eval "$(docker-machine env myBoxName)"
到您.bash_profile
或您将在打开新的shell或终端时收到以下错误.
"Cannot connect to the Docker daemon. Is the docker daemon running on this host?"
如果在打开终端后启动docker容器,则可以eval "$(docker-machine env myBoxName)"
手动运行,也可以重新加载bash配置文件(source ~/.bash_profile
).
Docker Toolbox是一个不错的选择,但是目前看来,适用于Mac / Windows的Docker变得越来越好,并且Docker投入了大量时间来完善该应用程序。我建议安装Docker主要有两个原因:
安装非常简单:
brew cask install docker
Run Code Online (Sandbox Code Playgroud)
要安装docker-toolbox您可以参考以上文章
自制更新
我可以澄清一些事情:
brew cask commands were deprecated on 2020-12-01 with the release of Homebrew 2.6.0. Starting then, all brew cask commands succeeded but displayed a warning informing users that the command would soon be disabled. The message also provides the appropriate replacement.
brew cask commands were disabled on 2020-12-21 with the release of Homebrew 2.7.0. Starting then, all brew cask commands failed and displayed a warning informing users that the command is disabled. The message also provides the appropriate replacement.
Run Code Online (Sandbox Code Playgroud)
随着 Homebrew 2.8.0(发布日期待定)的发布,此禁用消息将被删除。
The alternative to brew cask <command> is to use brew <command>. In many cases, you can add the --cask flag to specify casks only. For example, brew cask install atom is now brew install atom or brew install --cask atom. There are some casks that share a name with formulae (e.g. wireshark) so adding --cask ensures that the cask is installed not the formula.
Run Code Online (Sandbox Code Playgroud)
我不是一个可靠的用户,但如果需要,我很乐意尝试并提供帮助。如果有任何问题,请随时指出正确的方向,并且可以使用 Homebrew 方面的反馈。
现在你可以像
brew install --cask docker
Run Code Online (Sandbox Code Playgroud)