Remote access from WSL2 host

I have a Windows workstation and I want to have it host docker and access it remotely from my old 2015 MacBook Pro for frontend development purposes.

I tried Docker Desktop and Docker inside WSL2 and had no luck. Docker works perfectly fine when I am on Windows but when I try to expose the 2375 port I get “API listen on [::]:2375” (instead of 0.0.0.0:2375)

I tried

  1. Disabling firewall on both systems (Windows and WSL).

  2. Editing daemon.json:

    • I added "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"] in the /etc/docker/daemon.json file.
    • After editing, I restarted Docker using sudo systemctl restart docker.
  3. Modifying systemd docker.service File:

    • Initially, I had the ExecStart line as /usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375.
    • Later, based on suggestions, I removed the -H fd:// -H tcp://0.0.0.0:2375 flags, but this didn’t resolve the issue.
  4. Overriding systemd docker.service File when using daemon.json:

    • I added
[Service]
 ExecStart=
 ExecStart=/usr/bin/dockerd

to /etc/systemd/system/docker.service.d/override.conf
Current Status:

  • Running systemctl status docker shows that Docker is active and running, and the logs indicate API listen on [::]:2375.
  • However, when checking with Get-NetTCPConnection -LocalPort 2375 in PowerShell, it shows Docker listening on ::1 (IPv6 loopback), not on 0.0.0.0.
daly@Daly-PC:~$ systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/docker.service.d
             └─override.conf
     Active: active (running) since Mon 2023-12-25 11:57:19 CET; 3min 57s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 3429 (dockerd)
      Tasks: 23
     Memory: 45.2M
     CGroup: /system.slice/docker.service
             └─3429 /usr/bin/dockerd --config-file /etc/docker/daemon.json

Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.930716561+01:00" level=warning msg="WARNING: API is accessible on http://0.0.0.0:2375 without encryption.\n   >
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.930757921+01:00" level=warning msg="WARNING: No blkio throttle.read_bps_device support"
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.930765341+01:00" level=warning msg="WARNING: No blkio throttle.write_bps_device support"
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.930769431+01:00" level=warning msg="WARNING: No blkio throttle.read_iops_device support"
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.930772811+01:00" level=warning msg="WARNING: No blkio throttle.write_iops_device support"
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.930785530+01:00" level=info msg="Docker daemon" commit=311b9ff graphdriver=overlay2 version=24.0.7
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.930810730+01:00" level=info msg="Daemon has completed initialization"
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.944678928+01:00" level=info msg="API listen on /var/run/docker.sock"
Dec 25 11:57:19 Daly-PC dockerd[3429]: time="2023-12-25T11:57:19.944699397+01:00" level=info msg="API listen on [::]:2375"
Dec 25 11:57:19 Daly-PC systemd[1]: Started Docker Application Container Engine.
  1. How can I properly configure Docker in WSL to listen on both the Unix socket and 0.0.0.0:2375 for IPv4 connections?
  2. Are there additional settings or steps I need to consider to ensure Docker listens on the desired IPv4 address?

Environment Details:

  • Windows Subsystem for Linux (WSL2)
  • Docker version: Docker version 24.0.7, build afdd53b
  • Operating System: 22H2 Build 22621.2861