admin管理员组

文章数量:1025518

I need a docker swarm test environment on my local windows host for visual studio container development.

However swarm communication is not working because the docker service is listening in its isolated network 192.168.65.0/24. These ports are not published on the host!
I tried to enable mirrored networking, which sets the docker-desktop wsl2 ip to my host ip, but the service or network=host containers are still using the isolated network.

I tried to forward the swarm ports to the docker service, but I still don't get inbound traffic from other nodes because I think the swarm service requires the source IP, which is overwritten from published ports, so not even a transparent proxy inside the container would help

services:
  relay:
    image: trajano/multisocat
    container_name: relay
    user: root
    ports:
      - "12377:2377"
      - "17946:7946"
      - "17946:7946/udp"
      - "14789:4789/udp"
    environment:
      SOCAT_MANAGER: "TCP-LISTEN:2377,fork TCP:172.17.0.1:2377"
      SOCAT_DISCOVERY_TCP: "TCP-LISTEN:7946,fork TCP:172.17.0.1:7946"
      SOCAT_DISCOVERY_UDP: "UDP4-RECVFROM:7946,fork UDP4-SENDTO:172.17.0.1:7946"
      SOCAT_OVERLAY: "UDP4-RECVFROM:4789,fork UDP4-SENDTO:172.17.0.1:4789"

I tried enabling Enable host networking but this always translates the source IP to 127.0.0.1, even from remote hosts. This doesn't even work for the swarm ports anyway.

Transparent networking is only available for windows containers, so that's no option.

Running docker without docker desktop in a mirrored wsl2 is also no option because visual studio requires docker desktop to run the container.

Has anybody successfully set this up? Is there any way to communicate directly with the docker swarm service on 192.168.65.3 without NAT translation to preserve the source ip?

If you could tell me how to run the dev container on a remote linux host from within visual studio, I would also accept it as an answer.

Right now, every time I want to test the container, I have to push the code with git to the server and run it there, which is super inconvenient

I need a docker swarm test environment on my local windows host for visual studio container development.

However swarm communication is not working because the docker service is listening in its isolated network 192.168.65.0/24. These ports are not published on the host!
I tried to enable mirrored networking, which sets the docker-desktop wsl2 ip to my host ip, but the service or network=host containers are still using the isolated network.

I tried to forward the swarm ports to the docker service, but I still don't get inbound traffic from other nodes because I think the swarm service requires the source IP, which is overwritten from published ports, so not even a transparent proxy inside the container would help

services:
  relay:
    image: trajano/multisocat
    container_name: relay
    user: root
    ports:
      - "12377:2377"
      - "17946:7946"
      - "17946:7946/udp"
      - "14789:4789/udp"
    environment:
      SOCAT_MANAGER: "TCP-LISTEN:2377,fork TCP:172.17.0.1:2377"
      SOCAT_DISCOVERY_TCP: "TCP-LISTEN:7946,fork TCP:172.17.0.1:7946"
      SOCAT_DISCOVERY_UDP: "UDP4-RECVFROM:7946,fork UDP4-SENDTO:172.17.0.1:7946"
      SOCAT_OVERLAY: "UDP4-RECVFROM:4789,fork UDP4-SENDTO:172.17.0.1:4789"

I tried enabling Enable host networking but this always translates the source IP to 127.0.0.1, even from remote hosts. This doesn't even work for the swarm ports anyway.

Transparent networking is only available for windows containers, so that's no option.

Running docker without docker desktop in a mirrored wsl2 is also no option because visual studio requires docker desktop to run the container.

Has anybody successfully set this up? Is there any way to communicate directly with the docker swarm service on 192.168.65.3 without NAT translation to preserve the source ip?

If you could tell me how to run the dev container on a remote linux host from within visual studio, I would also accept it as an answer.

Right now, every time I want to test the container, I have to push the code with git to the server and run it there, which is super inconvenient

Share Improve this question edited Nov 18, 2024 at 11:12 5andr0 asked Nov 18, 2024 at 10:40 5andr05andr0 2,1281 gold badge26 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

VS does now have limited support for running against a Docker daemon in WSL. See Run containers in WSL with VS Container Tools.

Short version:

  • Install Docker CE in WSL
  • Download the Docker CLI in windows, add it to %PAth%, and configure it to connect to the WSL Daemon
  • Set the environment VSCT_WslDaemon to 1 before launchin VS

I need a docker swarm test environment on my local windows host for visual studio container development.

However swarm communication is not working because the docker service is listening in its isolated network 192.168.65.0/24. These ports are not published on the host!
I tried to enable mirrored networking, which sets the docker-desktop wsl2 ip to my host ip, but the service or network=host containers are still using the isolated network.

I tried to forward the swarm ports to the docker service, but I still don't get inbound traffic from other nodes because I think the swarm service requires the source IP, which is overwritten from published ports, so not even a transparent proxy inside the container would help

services:
  relay:
    image: trajano/multisocat
    container_name: relay
    user: root
    ports:
      - "12377:2377"
      - "17946:7946"
      - "17946:7946/udp"
      - "14789:4789/udp"
    environment:
      SOCAT_MANAGER: "TCP-LISTEN:2377,fork TCP:172.17.0.1:2377"
      SOCAT_DISCOVERY_TCP: "TCP-LISTEN:7946,fork TCP:172.17.0.1:7946"
      SOCAT_DISCOVERY_UDP: "UDP4-RECVFROM:7946,fork UDP4-SENDTO:172.17.0.1:7946"
      SOCAT_OVERLAY: "UDP4-RECVFROM:4789,fork UDP4-SENDTO:172.17.0.1:4789"

I tried enabling Enable host networking but this always translates the source IP to 127.0.0.1, even from remote hosts. This doesn't even work for the swarm ports anyway.

Transparent networking is only available for windows containers, so that's no option.

Running docker without docker desktop in a mirrored wsl2 is also no option because visual studio requires docker desktop to run the container.

Has anybody successfully set this up? Is there any way to communicate directly with the docker swarm service on 192.168.65.3 without NAT translation to preserve the source ip?

If you could tell me how to run the dev container on a remote linux host from within visual studio, I would also accept it as an answer.

Right now, every time I want to test the container, I have to push the code with git to the server and run it there, which is super inconvenient

I need a docker swarm test environment on my local windows host for visual studio container development.

However swarm communication is not working because the docker service is listening in its isolated network 192.168.65.0/24. These ports are not published on the host!
I tried to enable mirrored networking, which sets the docker-desktop wsl2 ip to my host ip, but the service or network=host containers are still using the isolated network.

I tried to forward the swarm ports to the docker service, but I still don't get inbound traffic from other nodes because I think the swarm service requires the source IP, which is overwritten from published ports, so not even a transparent proxy inside the container would help

services:
  relay:
    image: trajano/multisocat
    container_name: relay
    user: root
    ports:
      - "12377:2377"
      - "17946:7946"
      - "17946:7946/udp"
      - "14789:4789/udp"
    environment:
      SOCAT_MANAGER: "TCP-LISTEN:2377,fork TCP:172.17.0.1:2377"
      SOCAT_DISCOVERY_TCP: "TCP-LISTEN:7946,fork TCP:172.17.0.1:7946"
      SOCAT_DISCOVERY_UDP: "UDP4-RECVFROM:7946,fork UDP4-SENDTO:172.17.0.1:7946"
      SOCAT_OVERLAY: "UDP4-RECVFROM:4789,fork UDP4-SENDTO:172.17.0.1:4789"

I tried enabling Enable host networking but this always translates the source IP to 127.0.0.1, even from remote hosts. This doesn't even work for the swarm ports anyway.

Transparent networking is only available for windows containers, so that's no option.

Running docker without docker desktop in a mirrored wsl2 is also no option because visual studio requires docker desktop to run the container.

Has anybody successfully set this up? Is there any way to communicate directly with the docker swarm service on 192.168.65.3 without NAT translation to preserve the source ip?

If you could tell me how to run the dev container on a remote linux host from within visual studio, I would also accept it as an answer.

Right now, every time I want to test the container, I have to push the code with git to the server and run it there, which is super inconvenient

Share Improve this question edited Nov 18, 2024 at 11:12 5andr0 asked Nov 18, 2024 at 10:40 5andr05andr0 2,1281 gold badge26 silver badges34 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

VS does now have limited support for running against a Docker daemon in WSL. See Run containers in WSL with VS Container Tools.

Short version:

  • Install Docker CE in WSL
  • Download the Docker CLI in windows, add it to %PAth%, and configure it to connect to the WSL Daemon
  • Set the environment VSCT_WslDaemon to 1 before launchin VS

本文标签: Docker Swarm on windows 11 not publishing swarm ports 7946 4789Stack Overflow