/
Docker and Network Cards

Docker and Network Cards

Introduction

When using Docker in environments with multiple network interfaces, one may encounter connectivity issues due to how network interfaces are accessed and configured. Two key factors can influence these issues: network profiles and the order of network interface access.

This documentation describes how to detect these issues and how to fix them.

Network Profiles

Windows categorizes networks into profiles such as Public, Private, and Domain, which determine firewall and sharing settings. Docker requires certain network functionalities that might be restricted under a Public profile. After a server (re-)start, Windows might classify some networks as Unidentified, defaulting them to a Public profile. In the graphics below we see how one can identify such cases using the PowerShell Get-NetConnectionProfile function. The second card listed is Unidentified and thus defaults to Public:

image-20250107-110023.png

To resolve this, use the PowerShell command Set-NetConnectionProfile -Name "Unidentified network" -NetworkCategory Private to change it to Private.

Automating the Fix

Create and store the script SetNetworkCategory.ps1 with this content:

Set-NetConnectionProfile -Name "Unidentified network" -NetworkCategory Private

Then follow the procedure described below in section Create Scheduled Task to create a schduled task named Set Network Category.

Network Interface Access Order

The order in which network interfaces are accessed affects routing decisions. Each interface has a metric that determines its priority for outbound traffic. Docker might bind to the first available interface, which could lead to issues if it's not the intended one.

Use the Set-NetIPInterface PowerShell command to modify interface metrics, ensuring the correct interface has the highest priority. This can be done after each server (re-)start using the task schedular.

Automating the Fix

Create and store the script SetInterfaceMetric.ps1 with this content:

Set-NetIPInterface -InterfaceAlias "Ethernet" -InterfaceMetric 10

Then follow the procedure described below in section Create Scheduled Task to create a schduled task named Set Network Interface Metric.

Create Scheduled Task

  • Open the Task Scheduler by running taskschd.msc: in the Run dialog box.

  • Create a new task by clicking on Action in the menu bar and select Create Task.

  • Configure the task:

    • Name the task

    • Choose Run whether user is logged on or not.

    • Set Run with highest privileges.

    • Under the Triggers Tab:

      • Click New....

      • In the Begin the task dropdown, select At startup.

      • Click OK.

    • Under the Actions Tab:

      • Click New....

      • In the Action dropdown, select Start a program.

      • In the Program/script box, type powershell.

      • In the Add arguments (optional) box, enter the following:

        -ExecutionPolicy Bypass -File "<INSERT FULL PATH TO THE SCRIPT>"
      • Click OK.

    • Under the Settings Tab:

      • Ensure Allow task to be run on demand is checked.

  • Complete the creation:

    • Click OK to create the task.

    • Enter password if prompted