Crowdbotics
Published in

Crowdbotics

A complete one-by-one guide to install Docker on your Mac OS using Homebrew

Beginner’s guide to install and run Docker on Mac OS

Configurations

TL;DR

$ brew install docker docker-machine$ brew cask install virtualbox
-> need password
-> possibly need to address System Preference setting
$ docker-machine create --driver virtualbox default
$ docker-machine env default
$ eval "$(docker-machine env default)"
$ docker run hello-world
$ docker-machine stop default
Docker installation using Homebrew

Step-by-step Installation Process

Docker installation via Homebrew

$ brew install docker$ docker --version
Docker version 18.09.5, build e8ff056
$ docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

Docker-Machine installation via Homebrew

$ brew install docker-machine
$ docker-machine create --driver virtualbox defaultCreating CA: /Users/yutafujii/.docker/machine/certs/ca.pem
Creating client certificate: /Users/yutafujii/.docker/machine/certs/cert.pem
Running pre-create checks...
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"

VirtualBox installation via Homebrew

$ brew install virtualbox --cask
Click “Allow” button and it’s done!

Create a new virtual machine

$ docker-machine create --driver virtualbox default[...]Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.xxx.xxx:xxxx v18.09.5
$ docker-machine env default
$ eval $(docker-machine env default)
$ docker run hello-world
$ docker-machine stop default

What we have done?

  • installed Docker, Docker Machine, VirtualBox
  • docker-machine createcreated a new Docker virtual machine (named ‘default’)
  • docker-machine envswitched your environment to your new VM (named ‘default’)
  • evaluse the docker client(your local computer/terminal) to create, load, and manage containers
  • docker runDocker client (your terminal) created the Docker deamon
  • pulled the first image ‘hello-world’
  • The Docker deamon created a container, streamed out that output to the Docker client
  • docker-machine stopshut down the virtual machine

Docker Machine CLI commands

active
config
create
env
help
inspect
ip
kill
ls
mount
provision
regenerate-certs
restart
rm
scp
ssh
start
status
stop
upgrade
url

Resources

Building A Web Or Mobile App?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yuta Fujii

Web developer, Data analyst, Product Manager. Ex investment banker( structured finance ). Learn or Die.