Setting up Docker development environment on Windows/Mac

Marco Franssen

Marco Franssen /

8 min read1502 words

Cover Image for Setting up Docker development environment on Windows/Mac

In this post I want to cover how you can setup a Docker development environment on Windows/Mac. As you might already know Docker requires a Linux kernel to run. Therefore we will always need a VM to run the actual Docker environment when you are on Windows or Mac OS. Hereby a few quotes from the Docker webpage to remember you what Docker is all about, or to give you a quick idea.

Docker provides a common framework for developer and IT teams to collaborate on applications. With a clear separation of concerns and robust tooling, organizations are able to innovate faster with greater control.


    Developers have the freedom to define environments, and the ability to create and deploy apps faster and easier. IT ops have the flexibility to quickly respond to change.


    Developers own all the code from infrastructure to app. IT ops have the manageability to standardize, secure, and scale the operating environment.*


    Docker gives you choice without complexity, from a laptop to a team, to private infrastructure and public cloud providers.

Ok enough chatting, for the impatient ones continue to TL;DR. For all the others lets continue reading.

Put the whale to the water

Lets have a look how we can get an environment running on Windows or Mac. In this tutorial I'm going to use Chocolatey. Chocolatey is a package manager for Windows. It allows you to install the software you require from PowerShell. This makes it really powerful to script all the software you require on your computer by putting it in a PowerShell script. When unfamiliar with Chocolatey I recommend you to have a look at the Chocolatey webpage and install the tool as described on their page.

For the readers using a Mac, I will mention when you have to slightly differ your approach. In all the other cases you can run the same commands. For Mac I will be using a similar tool as Chocolatey, called Homebrew. When unfamiliar with this tool I assume you know how to install the packages manually or just have a look at Homebrew to figure out how to set it up on your Mac.

From this point I assume you have Chocolatey/Homebrew installed. In case you don't I'll also assume that you know how to install the required tools manually by downloading the correct installers. In order to get a VM running for our Docker environment we are going to use docker-machine to setup a docker-machine on VirtualBox. So lets start by installing Virtualbox, docker-machine and Docker using Chocolatey. In case you have any of these tools already installed you can skip this step.

Install tools

cinst -y virtualbox
cinst -y docker-machine
cinst -y docker
brew install docker-machine
brew install docker


Now we have installed docker-machine we are able to create a new environment. In case you already had docker-machine installed we can first have a look on what machines we have available using the following command.

$ docker-machine ls
default   *        virtualbox   Running   tcp://           v1.11.2

In my case I already have the machine created. In case you also have a machine there already you might want to just use that one. For the ones started from scratch I will show you now how to create a machine.

$ docker-machine create --driver virtualbox default
Running pre-create checks...
Creating machine...
(staging) Copying /Users/ripley/.docker/machine/cache/boot2docker.iso to /Users/ripley/.docker/machine/machines/default/boot2docker.iso...
(staging) Creating VirtualBox VM...
(staging) Creating SSH key...
(staging) Starting the VM...
(staging) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect Docker to this machine, run: docker-machine env default

Note: In case you just created your machine from scratch, we first have to boot it. You can do so by running following command. In case your machine is already running you can skip this step.

docker-machine start

With the command shown previously we created a machine named default using the virtualbox driver. So when you run the docker-machine ls command now, you should have similar output as you have seen before. You will also be able to see if the machine is running. We also see in the last line of the creation output that there is a special command which will provide you the information in order to connect your Docker client to this specific machine (docker-machine env default). Lets configure the PowerShell environment to connect Docker to this specific machine.

$ docker-machine env default
$Env:DOCKER_HOST = "tcp://"
$Env:DOCKER_CERT_PATH = "C:\Users\marco\.docker\machine\machines\default"
$Env:DOCKER_MACHINE_NAME = "default"
# Run this command to configure your shell:
# & "C:\ProgramData\chocolatey\lib\docker-machine\bin\docker-machine.exe" env default | Invoke-Expression

Remember when you are running this command from Mac it will output it differently. The same goes when you are using Bash/Cygwin on Windows or when you are using the regular Command-Prompt on Windows. So just run the command in your preferred console and execute the command as shown in the output. In our case I'm going to continue using PowerShell, which means I will execute the command as we have just seen.


Lets configure our PowerShell.

& "C:\ProgramData\chocolatey\lib\docker-machine\bin\docker-machine.exe" env default | Invoke-Expression

For Mac users the command will be something like following on bash.

eval $(docker-machine env default)

Now we will be able to use Docker on Windows. Lets try using the docker/whalesay image to test our Docker environment.

$ docker run docker/whalesay cowsay "Awesome your Docker environment is running!"
/ Awesome your Docker environment is \
\ running!                           /
                   ##        .
             ## ## ##       ==
          ## ## ## ##      ===
      /""""""""""""""""___/ ===
 ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
      \______ o          __/
       \    \        __/

In this article I won't go much deeper in the usage of Docker itself. So things like creating your own images, multi-container solutions and other more in depth Docker stuff won't be covered as it is out of scope. Therefore I only want to point you to docker --help on your console and the Docker documentation for now, so I won't leave you completely in the dark. I might be publishing another post on how to run your project in Docker later.

Play time

The docker/whalesay image also has command line help which reveals some more options (docker run docker/whalesay cowsay -h). It reveals for example the whale can also think instead of talk (docker run docker/whalesay cowthink "Will he see the difference?"). Have fun playing around with the docker/whalesay image and the other options revealed in the help or simply try out some other images from the Docker hub.


If you finished playing around with Docker you might want to shutdown the VM using docker-machine stop default. Next time you want to use it again simply run docker-machine start default and docker-machine env default to start and configure your environment. Last but not least I would like to point you to the --help option. It will provide you with usage information on the command line options for every single command.

docker-machine --help
docker-machine create --help


As a bonus I want to give you all the commands we require to setup our environment in a PowerShell script. So feel free to save the contents in a ps1 file which you can call from your PowerShell.


cinst -y docker-machine
cinst -y docker
docker-machine create --driver virtualbox default
docker-machine start
& "C:\ProgramData\chocolatey\lib\docker-machine\bin\docker-machine.exe" env default | Invoke-Expression
docker run docker/whalesay cowsay -W 19 "Awesome your Docker environment is running!"

brew install docker-machine
brew install docker
docker-machine create --driver virtualbox default
docker-machine start
eval $(docker-machine env default)
docker run docker/whalesay cowsay -W 19 "Awesome your Docker environment is running!"

Finally, when you are finished playing arround with Docker, you might want to shut down your vm. You can do so by running.

docker-machine stop

In case you where one of the impatient ones, now realizing you have no clue what just happened when you called the commands in above example. Here you go for a second shot.


Again thanks for reading this article, and as always share your feedback and questions in the comments.

You have disabled cookies. To leave me a comment please allow cookies at functionality level.

More Stories

Cover Image for Using docker-compose for multi Docker container solutions

Using docker-compose for multi Docker container solutions

Marco Franssen

Marco Franssen /

In this article I want to show you the way for running your multi container solution on Docker. Docker Compose is a tool for defining and running multiple Docker containers using a single command. With Compose, you use a docker-compose file to configure your applications services. Then, using a single command, you create and start all the services from your configuration. In a previous article I have shown you how to setup a Docker development environment on Windows or Mac. In case you don't ha…

Cover Image for Run your Angular app in a Nginx Docker container

Run your Angular app in a Nginx Docker container

Marco Franssen

Marco Franssen /

Today you will learn how we can package our static html Angular app in a Docker container running Nginx. By packaging our app in a Docker container we will benefit from the fact that we will have some immutable infrastructure for our app. Immutability will give you many benefits when it boils down to maintaining a platform. Things that can not change state also can't lead to surprises in a later stage. Immutability is also well known in functional programming languages. I won't list all the adva…

Cover Image for From errbacks to Promises in Node

From errbacks to Promises in Node

Marco Franssen

Marco Franssen /

In javascript world many APIs and libraries require you to implement most logic using callbacks. As of ES6, also referred to as ES2015, we can use the native Promise API. In most modern browsers and the current releases of Node.js the Promise API is supported. This enables us to use Promises without any thirdparty libraries. In Node.js we all know most of the libraries or built-in components are using callbacks. Those callbacks all have the same method signature, also referred to as errbacks. A…

Cover Image for Ssl certificate for your Azure website using Letsencrypt

Ssl certificate for your Azure website using Letsencrypt

Marco Franssen

Marco Franssen /

Letsencrypt is a free automated service which provides you SSL certificates for free. Although the certificates are only valid for 3 months, this shouldn't be a bottleneck as you can fully automate the certificate request and renewal. Letsencrypt comes with a python client which you can use to make a certificate request. Letsencrypt can be ran from a Linux OS. In this blogpost I will show you how to use the Letsencrypt Vagrant box (Ubuntu vm) to authorize the certification request for your Azur…