Part 2: Run Windows Containers On Windows Docker Host

In this article, I’ll show you how I connect to a Docker Host running on Windows Nano Server 2016 using a remote Docker Client.

For Part 1 article visit:

  • Part 1: How To Install Docker On Windows Nano Server 2016

In the 1 article, I mentioned that Nano Sever can’t pass TTY text to the console there for we need to use a remote client to manage Windows Containers running on Docker.

To get, the remote client and host to communicate properly I’ll need to configure both client and host as you will see below.

The first step, Is to create a .Json file on the Nano Host.

To get started, I’ll create a .JSON configuration file on my Nano host that will allow access to the host using port 2375.

To get this done, You will need to Open the firewall.

new-item -Type File c:\ProgramData\docker\config\daemon.json

Once the file Is created, I’ll allow remote connection to the Docker engine on port 2375.

Add-Content 'c:\programdata\docker\config\daemon.json' '{ "hosts": ["tcp://0.0.0.0:2375", "npipe://"] }'

Next, I’ll restart the Docker service.

Restart-Service docker

On the Docker Client machine, I’ll Download and Install the Docker remote Client using the cmdlet below:

Invoke-WebRequest "https://download.docker.com/components/engine/windows-server/cs-1.12/docker.zip" -OutFile "$env:TEMP\docker.zip" -UseBasicParsing

Then, extract the file

Expand-Archive -Path "$env:TEMP\docker.zip" -DestinationPath $env:ProgramFiles

Next, I’ll add the Docker Engine to the command line environment variable

$env:path += ";c:\program files\docker"
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Docker", [EnvironmentVariableTarget]::Machine)

To connect to my Docker Host and create a new Nano Server Container I’ll use the line below:

docker -H tcp://<IPADDRESS>:2375 run -it microsoft/nanoserver cmd

I can also Add the Docker host as a permanent variable to my Client

$env:DOCKER_HOST = "tcp://<ipaddress of server>:2375"

Leave a Reply