Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Docker Toolbox on a Mac via command line

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; open /Applications/Docker.app

like image 310
Mike Rylander Avatar asked Sep 23 '15 16:09

Mike Rylander


People also ask

How do I install Toolbox on Mac?

Install Docker Toolbox by double-clicking the package or by right-clicking and choosing “Open” from the pop-up menu. The installer launches an introductory dialog, followed by an overview of what's installed. Press Continue to install the toolbox.

Which command installs Docker on the Mac?

Double-click Docker. dmg to open the installer, then drag the Docker icon to the Applications folder. Double-click Docker. app in the Applications folder to start Docker.


2 Answers

Deprecation Warning

Docker Toolbox and Docker Machine have both been deprecated. Docker Desktop is the officially recommended replacement.

Original Answer

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).

like image 98
Mike Rylander Avatar answered Sep 16 '22 16:09

Mike Rylander


Docker Toolbox is a good option but currently it seems like Docker for Mac/Windows is becoming better and Docker is investing a lot of time polishing the app. I recommend installing Docker mainly for 2 reasons:

  1. It doesn't interfere with Docker-Toolbox
  2. It runs on HyperKit and therefor runs on you own localhost rather than a Docker Machine IP.

The installation is quite simple:

brew cask install docker 

To install docker-toolbox you can refer the above post

like image 31
Alexander Luna Avatar answered Sep 19 '22 16:09

Alexander Luna