通过命令行在Mac上安装Docker Toolbox [英] Install Docker Toolbox on a Mac via command line
问题描述
更新:正如丹尼斯
Docker for Mac 现在存在,这是Docker Toolbox的替代品。你可以通过自制桶子获得它:
brew cask install docker
我发现Docker Toolbox可以通过brew / cask获得
#Install Homebrew
ruby -e$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
#安装Cask
brew install caskroom / cask / brew-cask
#安装docker工具箱
brew cask install docker-toolbox
一旦Docker Toolbox安装后,您可以使用使用Docker Machine 指南设置Docker环境。
#创建docker机
docker-machine create --driver virtualboxmyBoxName
#启动docker机器
docker-machine start myBoxName
#此命令允许在终端中使用docker命令
eval$( docker-machine env myBoxName)
#在这一点上可以运行任何docker或docker-compose命令,你想要
docker-compose up
在此过程结束时,添加 eval$(docker-machine env myBoxName)
到您的 .bash_profile
,或者打开新的shell或终端时,您将收到以下错误。
无法连接到Docker守护程序,Docker守护程序是否在此主机上运行?
如果在打开终端后启动Docker容器,可以运行 eval$(docker-machine env myBoxName)
手动或重新加载您的bash配置文件( source〜/ .bash_profile
)。
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)?
Update: As pointed out in a commend by Dennis
Docker for Mac now exists, which is an alternative to Docker Toolbox. You can get it via the homebrew cask:
brew cask install docker
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
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
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.
"Cannot connect to the Docker daemon. Is the docker daemon running on this host?"
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屋!