通过命令行在 Mac 上安装 Docker Toolbox [英] Install Docker Toolbox on a Mac via command line
问题描述
我正在尝试在 Mac 上自动设置开发人员环境.该设置的一部分是安装 Docker 工具箱.我找不到有关如何通过命令行执行此操作的任何文档.如何自动执行此安装(必须通过命令行触发)?
I am trying to automate setting up a developer environment on Mac. Part of that setup is installing the Docker Toolbox. I cannot find any documentation on how do to this via command line. How can I automate this installation (must be triggered via command line)?
更新:正如 丹尼斯
Docker for Mac 现在存在,它是 Docker Toolbox 的替代品.你可以通过 homebrew cask 获取它: brew cask install docker;打开/Applications/Docker.app
Docker for Mac now exists, which is an alternative to Docker Toolbox. You can get it via the homebrew cask:
brew cask install docker; open /Applications/Docker.app
推荐答案
弃用警告
Docker 工具箱 和 Docker Machine 都已弃用.Docker Desktop 是官方推荐的替代品.
Deprecation Warning
Docker Toolbox and Docker Machine have both been deprecated. Docker Desktop is the officially recommended replacement.
我发现 Docker Toolbox 可以通过 brew/cask 获得
I found that Docker Toolbox is available via 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
安装 Docker Toolbox 后,您可以使用 开始使用 Docker Machine 设置您的 docker 环境 指南.
Once Docker Toolbox is installed you can setup your docker environment using the Get started with Docker Machine guide.
# 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
在此过程结束时,将 eval "$(docker-machine env myBoxName)"
添加到您的 .bash_profile
中,否则您将收到以下错误你打开一个新的 shell 或终端.
At the end of this process, add eval "$(docker-machine env myBoxName)"
to your .bash_profile
or you will get the following error when you open a new shell or terminal.
"无法连接到 Docker 守护进程.docker daemon 是否在这台主机上运行?"
如果您在打开终端后启动 docker 容器,您可以手动运行 eval "$(docker-machine env myBoxName)"
,或者重新加载您的 bash 配置文件 (source~/.bash_profile
).
If you start the docker container after opening the terminal, you can either run eval "$(docker-machine env myBoxName)"
manually, or reload your bash profile (source ~/.bash_profile
).
这篇关于通过命令行在 Mac 上安装 Docker Toolbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!