通过命令行

时间:2015-09-23 16:26:00

标签: macos automation docker docker-toolbox

我正在尝试在Mac上自动设置开发人员环境。部分设置是安装Docker Toolbox。我无法通过命令行找到有关如何执行此操作的任何文档。如何自动执行此安装(必须通过命令行触发)?

更新:正如Dennis

的推荐所指出的那样
  

Docker for Mac现在已存在,它是Docker Toolbox的替代品。您可以通过自制软件桶获取它:brew cask install docker

3 个答案:

答案 0 :(得分:85)

我发现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

安装Docker Toolbox后,您可以使用Get started with Docker Machine指南设置泊坞窗环境。

# 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或终端时会出现以下错误。

"Cannot connect to the Docker daemon. Is the docker daemon running on this host?"

如果您在打开终端后启动泊坞窗容器,则可以手动运行eval "$(docker-machine env myBoxName)",也可以重新加载bash配置文件(source ~/.bash_profile)。

答案 1 :(得分:5)

Docker Toolbox是一个不错的选择,但目前似乎Docker for Mac / Windows正在变得更好,而Docker正在投入大量时间来完善应用程序。我建议主要安装Docker有两个原因:

  1. 它不会干扰Docker-Toolbox
  2. 它在HyperKit上运行,因此在你自己的localhost而不是Docker Machine IP上运行。
  3. 安装非常简单:

    brew cask install docker
    

    要安装docker-toolbox,您可以参考above帖子

答案 2 :(得分:5)

自制更新

我可以澄清一些事情:

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.

随着 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.

我不是一个可靠的用户,但如果需要,我很乐意尝试并提供帮助。如果有任何问题,请随时向我指出正确的方向,并且可以使用 Homebrew 方面的反馈。

现在你可以像这样跑

brew install --cask docker