Sharing Docker Daemon From Windows to Local Network

To share the Docker Daemon running on a Windows machine with other devices on your local network, you can use the netsh command to perform port forwarding. This will allow you to access the Docker Daemon remotely using the machine’s IP address and the forwarded port. Here’s how you can do it:

  1. Open Command Prompt as Administrator: To execute the netsh command, you need administrative privileges. Right-click on the Command Prompt and choose “Run as administrator.”

  2. Enable Docker Daemon Port: By default, the Docker Daemon listens on localhost (127.0.0.1) for security reasons. To enable it to listen on all interfaces, including your local network, you’ll need to modify the Docker Daemon configuration. Locate the daemon.json file located at C:\ProgramData\Docker\config\daemon.json and add the following configuration:

    1
    2
    3
    
    {
      "hosts": ["tcp://0.0.0.0:2375", "npipe://"]
    }

    Save the file and restart the Docker service for the changes to take effect.

  3. Add Port Proxy Rule: Use the netsh command to set up port forwarding from a specific IP address and port to the Docker Daemon’s IP address and port. In this example, we’ll forward port 2375 from the machine’s IP address 192.168.100.7 to localhost:2375 where the Docker Daemon is running.

    1
    
    netsh interface portproxy add v4tov4 listenport=2375 connectaddress=127.0.0.1 connectport=2375 listenaddress=192.168.100.7 protocol=tcp

    This command forwards incoming traffic on port 2375 of the specified IP address (192.168.100.7) to the Docker Daemon running at 127.0.0.1:2375.

  4. Access Docker Daemon Remotely: Now, you should be able to access the Docker Daemon from other devices on your local network by using the IP address of the Windows machine (192.168.100.7 in this case) and port 2375. For example, you can use the following command to check if the Docker Daemon is reachable:

    1
    
    docker -H tcp://192.168.100.7:2375 info

    Replace 192.168.100.7 with the actual IP address of your Windows machine.

Remember that exposing Docker Daemon to the network without proper security measures can pose a security risk. Ensure that your network and Docker Daemon are properly secured and consider using TLS for encrypted communication if you plan to access the Docker Daemon over the network.

0%