Setting up Docker on Windows

Containers give developers a way to rapidly re-create their environment at the drop of a hat. Containers are coming to Windows really soon. Docker is a great tool to help you manage all of those magical containers.

I recently set up Docker in my desktop and I lived to talk about it. Here’s the scoop:

  1. If you haven’t already, install Hyper-V
  2. Make sure you have an external Hyper-V switch.
    1. You can check using Get-VMSwitch | where { $_.SwitchType -eq "External" }
    2. If none exist, create one. I named mine “docker”.
  3. Create a few helpful environment variables. If you don’t set them up, you’ll have to keep passing them as command line flags to docker and then you’ll get all kinds of mad.
    1. HYPERV_VIRTUAL_SWITCH – give this the name of the switch you created in 2.2
    2. MACHINE_STORAGE_PATH – this is where your docker VMs are going to live. I used G:\docker.
  4. Add C:\docker to your PATH environment variable.
  5. Directly download docker-machine from
    1. Scroll down to the “Downloads” section and grab the appropriate Windows executable.
    2. Once you download it, rename the file to docker-machine.exe (as opposed to whichever architecture specific file you have).
    3. Copy docker-machine.exe into C:\docker.
  6. Download the docker client from
    1. Same deal as before – scroll down to “Downloads” and get the appropriate windows executable.
    2. Rename the file to docker.exe.
    3. Copy docker.exe into C:\docker.
  7. Open up some kind of terminal and execute docker-machine create -d hyperv dockervm. Because of an existing issue in docker-machine, this needs to be an administrator terminal.
    Make a new thing, internet robot!
  8. You can execute docker-machine env dockervm to find out how to connect to this VM. It’s going to tell you something like… & "C:\docker\docker-machine.exe" env default | Invoke-Expression. Run that.
    This just sets up your docker environment so you can do more stuff. Trust me, this confusion only happens once.

At this point, you’re pretty much all set. You can run docker run hello-world and you’ll get a message that you’ve set everything up and life is good. You can also connect directly to that VM you just created using docker-machine ssh dockervm.

Awww... it's a whale!

Awww… it’s a whale!

Yeah, it’s Linux. But right now, that’s how you’re going to be working with containers.

This is just to get started, too. There’s a lot more than you can do with Docker and better Windows support is on the way (both from Docker and Microsoft’s support for containers). Getting started with Docker is the first step.

You can try out Windows containers today on Windows running either 2016 preview builds or Windows 10 (10.0.10586 or later). Check out the Windows Container Quick Start for more

6 Comments. Leave new

  • What is the name of that terminal shell font?
    Is it a custom font or is it a free font that available for use?
    I would love to use that for my shell if possible.
    Thanks for any information you can provide.

    • The font is monofur. It’s available for free from a number of places, I believe my installation is Monofur for Powerline. I should also note that I’m using cmder; monofur is not available in both the default Windows command shell and PowerShell.

      I just switched to Source Code Pro – monofur’s single quote and backtick characters are alarmingly similar. That might not be a problem for you.

      • Thanks for the tip – I do see what you mean and decided to use a different one than monofur
        I have found the Envy Code font is pretty nice I like it a little better than Source Code Pro although they both are installed.

  • What version of Windows are you using? I am running Windows 7 and Hyper-V appears to be only for Windows Server.


Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

This site uses Akismet to reduce spam. Learn how your comment data is processed.