Connecting To Docker In Nano Server

This article is about creating a firewall path in between the local machine and the Nano Server to get connected with the Docker.  This will let us access the local machines to access Docker.

Step 1 Connecting to Nano Server using PowerShell

  • Open PowerShell with administrator privileges. Run the following code to connect with the Nano Server.

    Enter-PSSession -ConnectionUri "" -Credential (Get-Credential)
  • This will ask you for the username and password of the Nano Server VM. Enter the credentials and login.

    Nano Server

Step 2 Adding firewall rule

  • Now, we are going to add a firewall rule for incoming requests using the TCP port. This will help you make Docker respond to the requests from that port number. Run the following command to create the firewall rule.

    netsh advfirewall firewall add rule name="Docker daemon" dir=in action=allow protocol=TCP localport=2375

    Nano Server

Step 3 Creating Host Configuration

  • Our next activity is to create the Host configuration file that holds the host key. This will be saying to allow all the IP ranges through TCP port 2375. First, we shall create an empty JSON file in the Nano Server. Run this command for that.

    new-item -Type File c:\ProgramData\docker\config\daemon.json
  • Now, add the host key into the daemon.json file which was created previously. For this, run the below code,

    Add-Content 'c:\ProgramData\docker\config\daemon.json' '{ "hosts": ["tcp://", "npipe://"] }'
  • The above code will now create a firewall rule allowing all IP address ranges since we have used
  • Use the command Get-Content 'c:\ProgramData\docker\config\daemon.json' to get the host configuration which you saved now.

Step 4 Checking the Connectivity with Docker

  • After saving the profile, restart the Docker using this command.
    Restart-Service docker
  • Now check whether Docker is running by using this command.
    Get-Service docker

    Nano Server

We have successfully created a Docker Service in the Nano Server.

Similar Articles