JVM microservices – how to run Docker containers on Windows

Microservices is one of the loudest IT buzzwords, everybody’s anxious to try it. But what Linux and MacOS users get for free is not so easy in Windows. This guide shows how to setup Windows environment for running Docker containers, as a basis for microservice architecture projects.


  • GIT-SCMGit For Windows project, containing git, bash and other Linux tools
  • Environment variablesWindows environment variables, assumed to be managed via Control Panel

In fact, Docker Toolbox for Windows comprises everything for running Docker containers because it is bundled with GIT-SCM project. Unfortunately the default installation has few drawbacks

  • Impossible to skip bundled GIT SCM installation, even when newer version already installed
  • No option for changing GIT SCM destination
  • Сommand line tools ain’t added to PATH environment variable
  • Impossible to configure additional git parameters unlike in original GIT-SCM installer

To overcome those and to achieve the better environment flexibility, I’ll explain in this guide a longer way, where all required software will be installed from separate bundles.

Following old habit I tend to avoid installation of tools that are planned to be used from command line to C:\Program Files\ folder. Instead, I’m using c:\opt, d:\usr, etc., i.e. folder name without spaces. This guide will highlight steps where software is planned to be installed in folder different from C:\Program Files\.

Setup MSYS2

MSYS2 is a basis project for GIT-SCM and provides advantages over GIT-SCM,

Advantages over


  • More command line oriented, not limited to git usage
  • Symbolic link support
  • Built-in package manager pacman, ported from Arch Linux distributive
    • Possibility to install arbitrary tools not included into MSYS2 distributive
    • Possibility to upgrade MSYS2 core from command line

Installation steps

  1. Run installer from and follow instructions
  2. Use d:\opt\msys as a destination folder
  3. After installation is completed add d:\opt\msys\usr\bin to PATH environment variable

By default MSYS2 uses own directory for user home, so instead C:\Users\ your home will be located in d:\opt\msys\home folder. This behavior can be overridden by setting environment variable HOME to preferred value.

Setup Docker Toolbox

Installation steps

  1. Run Windows installer from and follow instructions
  2. Use d:\opt\docker as a destination folder
  3. After installation is completed, uninstall GIT SCM via Control Panel, we will use MSYS2 installed before

Setup ConEmu

MSYS2 provides possibility to run bash but as soon as you run many consoles you start to get lost in those floating windows. ConEmu comes to the rescue, providing comfortable tabbed interface for bash shells along with additional functionality improving command line experience and better integration on`Windows`.

  1. Run installer from and follow instructions, alpha releases can be used
  2. Create ConEmu task for running bash console and run it on program startup
    Figure 1. ConEmu task for running MSYS2
    Figure 1. ConEmu task for running MSYS2
  3. Create new consoles inside single ConEmu window
    Figure 2. ConEmu single window settings
    Figure 2. ConEmu single window settings
  4. Integrate with Windows shell, environment variable CHERE_INVOKING forces MSYS2 to use current directory as a working directory for new bash instance
    Figure 3. ConEmu shell integration settings
    Figure 3. ConEmu shell integration settings

    Figure 4. ConEmu shell integration
    Figure 4. ConEmu shell integration

Verify that everything works

  1. Start ConEmu program (should start with bash console running inside new tab)
  2. Open new console in ConEmu with Ctrl+X hotkey, this is just to check Ctrl+X works
  3. Go to /d/opt/docker/ folder and run ./ there
  4. Execute docker run hello-world command
  5. Check output, it should looks like below, refer to Docker Guide for latest actual information about the output
$ docker run hello-world

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:

For more examples and ideas, visit:

docker-machine tool

Docker Toolbox installs VirtualBox and creates own VM inside it named default. Although VM management can be performed via VirtualBox UI, there’s useful docker-machine tool. It allows to interact with VirtualBox VM from command line. Some useful commands are shown below.

  • $ docker-machine ls – list machines and their statuses
  • $ docker-machine stop default – stop default VirtualBox VM
  • $ docker-machine start default – start default VirtualBox VM
  • $ docker-machine help – for more information

Improve Git experience on Windows

If you plan to use git then pay attention to steps below, otherwise this section could be skipped.

Line endings

GIT-SCM as well as other sources advice to use core.autocrlf equals to true while working with git on Windows. Execute command below to set this parameter for all git repositories.

$ git config --global core.autocrlf true

Password caching

Working with remote repositories via HTTP / HTTPS requires entering user name password. It’s good to use credentials helper that caches passwords, so there no need to type them each time. For GitHub it’s easy and explained in this article. But this approach doesn’t fit well with BitBucket repositories.

Git Credential Manager for Windows project works fine with both GitHub and BitBucket, but currently it can be used only with git installed via GIT-SCMtrack сorresponding issue.

The solution is to use Git Credential Manager for Windows predecessor that works fine with any git installation.


This is the first post about JVM based projects based on microservice architecture, mostly related to Windows specific features.

Next post will explain how to create and run sample project using environment described in this guide.

Stay tuned.

Notify of

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

Newest Most Voted
Inline Feedbacks
View all comments
Back to top button