Easy Docker on OS X
Docker is getting even easier to use on OSX now thanks to Docker Toolbox
Join the DZone community and get the full member experience.Join For Free
using docker on os x is getting easier. previously, it involved setting up boot2docker by hand. with the new docker toolbox (which wraps boot2docker and kitematic, among others), installing docker is almost trivial.
the first step is to download and install
. in case it encounters a problem during the initial run, i recommend reinstalling or updating your virtualbox first. the major component of docker toolbox is
, which serves a gateway to a catalog of docker images. you can launch a container based on a particular image. the first image,
, is always a good start. it contains an instance of
, a popular web server. click on the create button and wait for a moment while the image is being downloaded from
. the progress can be monitored from the container logs.
once the container is running, we can test it. go to the settings tab and then ports. it will show the ip address and port on the os x system where nginx is serving the page. now all you need to do is to open your favorite web browser to go to that address and you will see the html content served by nginx inside the container.
to change the content of html file, go to the volumes setting and click on
. kitematic will map it to a directory on your os x. this is the fun part: edit the html file, save it, and refresh your web browser. it is fun to see this round-trip of bits and bytes, a file from the os x system goes into the container, served via nginx running in linux, and then appears as a web content through a web browser.
if you want to play with docker client command line, simply click the docker cli button on the bottom left corner of kitematic. this will open the terminal app with access to the docker executable. try it by running:
$ docker --version docker version 1.9.1, build a34a1d5
or by running this minimalistic node.js image (obviously, it is a complicated way to compute the square root of a number):
$ docker run iron/node node -e "console.log(math.sqrt(2))" 1.4142135623730951
still afraid of docker hassle? hopefully this post shows that the fear is not justified.
Published at DZone with permission of You Can Win. See the original article here.
Opinions expressed by DZone contributors are their own.