Jan Carlo Viray React · Angular · Node · SQL · Cloud · Entrepreneurship

Portfolio ·  LinkedIn ·  Twitter ·  Stack Overflow ·  Github ·  Contact Me

Install Docker in Mac OSX

Docker is one of the “disruptive” technologies I have recently been watching. It is a great new paradigm for devops and deployment. I believe the future is on containers. Here’s a quick intro on installing it on your Mac OSX machine.

Using Docker in Mac OSX

“Because the Docker Engine uses Linux-specific kernel features, you’ll need to use a lightweight virtual machine (VM) to run it on OSX. You use the OS X Docker client to control the virtualized Docker Engine to build, run and manage Docker containers.” - docker.com

Before continuing, install Boot2Docker. It will install a virtual machine (using VirtualBox) that is all set up to run the Docker daemon. Click here to get the latest releases.

I added per-line information to hopefully make things a bit clearer.

Quick Start

# assuming that Boot2Docker is installed...

# initialize boot2docker and download latest ISO
# and generate public/private key pair
boot2docker init

# start VM and docker daemon (server)
boot2docker start

# initialize shell
$(boot2docker shellinit)

# upgrade
boot2docker stop
boot2docker download
boot2docker start

# test run docker
# note that if this image is not found,
# it will force download it and create
# a small container with an executable
# that prints a brief ‘Hello from Docker’
# message
docker run hello-world

# want to download a full-blown ubuntu?
# note that it could be a ~200mb download
# after it downloads, you’ll be inside
# the bash shell. `exit` to exit
docker run -it ubuntu bash

# check docker version
docker version

# if you are getting a FATA[0000] error
# your shell might not be provisioned
$(boot2docker shellinit)

# the latest version of boot2docker
# sets up a host-only network adapter
# which provides access to the
# container’s port. try running an
# nginx image at port 80
docker run --rm -i -t -p 80:80 nginx

# get boot2docker IP
boot2docker ip

# access the image’s port 80
open $(echo ‘http://’$(boot2docker ip))

Let me know your experience and opinions about Docker through the comments below.

If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!