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
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).
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:
It doesn't interfere with Docker-Toolbox
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
Homebrew Updates
I can clear up a few things:
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.
With the release of Homebrew 2.8.0 (release date TBD), this disable message will be removed.
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.
I'm not much of an ansible user but I'm happy to try and help out if needed. Feel free to point me in the right direction if anything is blocked and could use feedback from the Homebrew side of things.
Now you can run like
brew install --cask docker
Related
I a trying to install some cli tools to use globally. Running the install command via npm never works - I get command not found [package] whenever I check [package] -v. I have tried this with netlify-cli, firebase-tools, and heroku.
However, when I install heroku via homebrew (brew tap heroku/brew && brew install heroku) it seemed to work fine. The version info showed up on heroku -v.
If it's relevant, I'm using MacOS 13.0, and ohmyzsh on iTerm2. I tried the built-in terminal (which also runs zsh) but had no luck.
How can I reliably use npm in order to install tools?
i want to install virtual box on mac os EI Captain with homebrew and also if i want to install more packages with homebrew how can i know that package is available in homebrew?
Thanks
First, you’ll need the command-line tools for Xcode installed. On a modern Mac OS X system, you can install these just by running the following command in a Terminal window. You could also install the full Xcode application from Apple, if you prefer — but that takes up more space on your Mac and isn’t necessary.
xcode-select --install
Next, install Homebrew. You can just open a Terminal window, copy-paste the following command, and press Enter:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
This script informs you what it will do. Press Enter and then provide your password to install it. By default, it installs Homebrew so you can use the brew command without typing the sudo command and providing your password.
Run the following command once you’re done to ensure Homebrew is installed and working properly:
brew doctor
Once you’re done, run the following command to install Homebrew Cask. It uses Homebrew to install Cask:
brew install caskroom/cask/brew-cask
Now you can install the Virtual box by entering the following commands
brew install vagrant-completion
brew cask install virtualbox
brew cask install vagrant
brew cask install vagrant-manager
For knowing that your package is available or not you can search your desire package by the following commands
For Open-Source Utilities
brew search name-of-your-package
For graphical Apps
brew cask search name-of-your-app
For installing Graphical Apps run
brew cask install name-of-your-app
For installing Open-Source Utilities run
brew install name-of-your-package
I installed Docker on my Mac OSX machine (El-Capitan) using Homebrew.
But when I try to run it, it gives me the error shown below.
$ docker --version
Docker version 17.06.0-ce, build 02c1d87
$ docker-compose --version
docker-compose version 1.14.0, build unknown
$ docker-machine --version
docker-machine version 0.12.2, build 9371605
$ docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
How can I fix it?
There is no need to uninstall docker, I hit this hurdle as well and on Mac, follow these steps
Go to the application folder and click the docker icon
wait for it to start
Once the docker starts, you can run any docker command without any issue
It looks like you need to start the Docker daemon first. Check the caveats section of brew info docker-machine.
$ brew info docker-machine
docker-machine: stable 0.12.2 (bottled), HEAD
Create Docker hosts locally and on cloud providers
https://docs.docker.com/machine
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/docker-machine.rb
==> Dependencies
Build: go ✔, automake ✔
==> Requirements
Build: git ✔
==> Caveats
To have launchd start docker-machine now and restart at login:
brew services start docker-machine
Or, if you don't want/need a background service you can just run:
docker-machine start
I had installed minikube a few months ago and wanted to upgrade as newer versions are available.
I am unable to find out how to upgrade minikube. I see a feature request for an upgrade command here - https://github.com/kubernetes/minikube/issues/1171
I tried to then uninstall minikube and hit another brickwall again. I don't see a command to uninstall minikube. The information that came closest to this was not very helpful - https://github.com/kubernetes/minikube/issues/1043
I guess we need ways to upgrade these (at least once every 6 months or so).
Before reinstall minikube (OS X), check the following:
Make sure that you have brew updated:
brew update
Make sure that you already have cask installed:
brew cask install minikube --verbose
Finally, execute the following command in the same directory you've installed minikube previously (usually /usr/local/bin/):
brew cask reinstall minikube
If you see an output similar to this:
Error: It seems there is already a Binary at '/usr/local/bin/minikube'; not linking.
Remove the existing binary:
rm /usr/local/bin/minikube
Now, you should able to reinstall (upgrade) minikube. :)
brew upgrade minikube
Just upgrade minikube with brew
This should do the trick.
brew cask reinstall minikube
First, unlink the existing minikube from /usr/local/bin then reinstall:
$ sudo rm -rf /usr/local/bin/minikube # unlink existing minikube
$ brew update # update brew itself
$ brew cask reinstall minikube # reinstall latest minikube
An updated way is to use this:
brew cask upgrade minikube
Process to update:
Minikube is an executable: Re-install minikube is an upgrade.
Optionally you can remove ~/.minikube which will make minikube completely re-initialize and also update your kubernetes version (if a new version has been made available for minikube).
minikube delete
sudo rm -rf ~/.minikube
re-install minikube and it should work
if you are using Windows machine and Chocolatey package manager -
Step 1: run PowerShell as administrator
Step 2: run following command choco upgrade minikube
More on chocolatey https://chocolatey.org/
As of early 2020, and based on the guidance provided by this answer, minikube is no more available as a cask. You need to run:
brew install minikube
Minikube is no longer available in cask and calling brew cask while performing install, upgrade, or reinstall is deprecated! Use the below syntax instead:
Make sure brew is updated:
brew update
Then, to install, use:
brew install minikube
To upgrade, use:
brew upgrade minikube
To reinstall, use:
brew reinstall minikube
If you're reading this in 2020+:
brew upgrade minikube
On linux:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v1.22.0/minikube-linux-amd64 && chmod +x minikube && sudo cp minikube /usr/local/bin/ && rm minikube
Change the version you want to download. Above script uses 1.22.0
Just try brew upgrade minikube
brew reinstall minikube --cask did the trick for me
In order to upgrade in Windows, type:
minikube start
The following is the output you will get (make sure you are connected to internet):
Here is a newer version of Minikube available (v0.28.0). Download it here:
https://github.com/kubernetes/minikube/releases/tag/v0.28.0
if you don't get the above message then first run
minikube config set WantUpdateNotification true
then do,
minikube start
Before that, remove all the Minikube links from the system:
Remove the previous installation path.
From this folder, remove c:\Users\<user-name>\ .kube folder.
Am I correct to assume that installing Docker Toolbox is now the required method for installing docker-machine on OSX? I have a script that I've been using for onboarding my team of developers, which installs docker related tools like docker-machine, but it pulls it in through curl. This stopped working with the latest version. All their documentation says I need to install Docker Toolbox, with no indication of an alternative. Is there still a way to install it through the command line?
I installed virtualbox, docker, docker-machine and docker-compose all via homebrew, and worked like a charm to me.
$ brew install docker docker-compose docker-machine
if you don't have installed virtualbox, you could install it using homebrew cask.
$ brew cask install virtualbox
One important thing you obtain when you installing it this way, is the bash completion. You need to install bash-completion, previously, for this benefit.
$ brew install bash-completion
Answered my own question. It's undocumented, but if you go to their github page, then click on releases, you'll see all the latest releases for the OS you're looking for. https://github.com/docker/machine/releases. Find the download you need, then run this:
$ curl -L https://github.com/docker/machine/releases/download/v0.4.0/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine
$ chmod +x /usr/local/bin/docker-machine
You can install it also with Homebrew
$ brew install docker-machine