Using the Newman Docker image in Windows, hassle free

Docker is one of the most well known container technologies and is quite the rage these days. We at Postman love Docker for its simplicity. It helps us by allowing a single software release to work on Windows, Mac-OSX and Linux, is extremely easy to set up, and abstracts away platform specific quirks of dependencies.

Last week, we released a Docker image that has Newman, Postman's command line collection runner bundled with it. This blog post mainly deals with using the Newman docker image on Windows. Some of our users have mentioned issues installing the Newman CLI on Windows, so this workaround might help them.

Broadly, the process involves three steps:

  1. Installing Docker on Windows
  2. Configuring Docker to work on Windows Command Prompt
  3. Downloading and running the Newman Docker image

Installing Docker on Windows

If you don't already have docker for windows installed on your system, follow these steps to install it. This process is also described in detail in the official Docker documentation.

  1. Download the setup (docker-install.exe) for the latest release of "boot2docker", which is a helper application that allows you to run Docker on windows. You can get the latest release here:
    > https://github.com/boot2docker/windows-installer/releases/latest
  2. Run the setup file downloaded in previous step. This will install the Docker Client for Windows, and other required components, such as Virtualbox and Git for Windows. Do restart your computer after installation.

  3. You should now see two new desktop icons, as shown below.
    New Shortcuts

  4. Run (Double Click) the "Boot2Docker Start" shortcut. This will create a public/private key pair for you, and initialize a new virtualbox machine. If all goes well, you'll see a shell as shown in the screengrab:
    Docker Shell
    Note: On my system, I had to change BIOS settings and enable support for VT-x.

  5. Test your docker installation, run this in the shell:

That basically is the installation of the core part of Docker. What follows is a few tweaks so that we can run Docker from the Windows Command Prompt (cmd.exe)

Configuring Docker to work on Windows Command Prompt

  1. Using docker with "cmd.exe" on Windows requires you to add a new directory to your system's %PATH% variable. You can add this by editing it in the system properties. Open "My Computer" > "Properties" > "Advanced" > "Environment Variables" > "Path" and append ;C:\Program Files (x86)\Git\bin to the value that is already present. If it's blank, add ;C:\Program Files (x86)\Git\bin. Log out, and log back in to ensure that the changes to %PATH% are propagated throughout your session.

  2. Open a new command prompt (cmd.exe) and type

    You should see the directory you just added in the output.

  3. In the Command Prompt, run the following commands, which will initialize the Boot2Docker VM if initialization is not done already, and then start the VM.

  4. Set the environment variables as mentioned in the output of previous step:
    Setting environment variables

  5. Test your command line setup by running the docker "hello world" image:

Running Newman from Docker

You're now all set to run docker from the windows Command Prompt. The rest of this tutorial assumes that you have a folder in your Desktop, called "collections" that has one Postman Collection file "testCollection.json". Here's how you can go about using Newman Docker image to run the "testCollection.json" file:

The -v /c/Users//Desktop/collections/:/tmp/collections part instructs Docker to mount the windows "Desktop\collections" folder to "/tmp/collections" on the Newman Docker image. Mounting volumes in this way allows Newman to directly write to the mounted paths, enabling you to make use of the HTML output and other features.

Checkout the Newman-Docker GitHub repository for advanced usage!

2 thoughts on “Using the Newman Docker image in Windows, hassle free”

Leave a Reply

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