Network communication between Windows + WSL2 + Docker - windows

I have a web app hosted in a Docker container and exposes port 5050 that is mapped to port 80 of the container.
The web app listens on 0.0.0.0:5050.
The Docker engine runs on WSL2.
Now when I open a browser on Windows and go to http://localhost:5050, everything works and I can see the web app.
But I don't understand how the request can reach the Docker container when I navigate to localhost on Windows.
Any ideas ?

The reason is that Docker for Windows uses a WSL2 backend, and is integrated with WSL distros.

Related

WSL2 - Docker without Docker Desktop - cloud_sql_proxy does not work with VPN

So far I have worked/developed with Windows 10, Docker Desktop and WSL2. Now I had to remove Docker Desktop for licensing reasons and decided to run Docker natively in my WSL2 distro. This also works flawlessly. I can access my Docker applications in WSL from Windows.
For the data connections I use the cloud_sql_proxy from Google.
Again, no problems here. However, they occur as soon as I turn on the VPN. Then I can't connect to the database anymore. Everything else works!
The following:
VPN turned off. Connect to the DB via the cloud_sql container. Everything Okay
turn on VPN. DB connection remains established, but breaks down as soon as a reconnect is necessary.
VPN switched on. LOG in container: net/http: TLS handshake timeout
Using
gcr.io/cloudsql-docker/gce-proxy:1.31.2
Windows 10
Ubuntu-20.04
VPN L2TP (Windows nativ)
Using the cloud_sql_proxy service instead of the Docker container works. Can anyone help me with this? Why does it not work with the Docker container?

Connect to the Docker container from host network

I have a WcfService under .NET Framework, it is older server-side of application. I need to migrate it to the Windows Docker container on machine with Windows 10.
Beside that there will be running few IIS containers, that will interact with this WcfService but container to container communication is clear to me.
Then I have a client desktop application that must also be able to connect to the WcfService. In configuration file I specify Port and Hostname of wcfservice so I can connect.
This client may run on any machine within same LAN as WcfService container.
How should I construct command docker run <params> wcfservice and are there any other steps (firewall, Hyper-V settings,...) I need to do so that LAN can see this service and how can I retrieve hostname and port from this container?

Connect to remote Docker Swarm from Windows

I would like to connect to a remote Docker Swarm (Ubuntu) from a Windows box.
In Linux it seams that you need to update the daemon.json file.
How do you achieve this in Windows?
Thanks!
The Docker engine has two parts, the daemon service (dockerd) that's running on your Ubuntu box, we'll call it the "server". Then the docker cli is what you can run from that server (docker) or from anything like your Windows machine (docker.exe). We'll call this the "client".
The client can talk to the server over two main ways, the socket, and a TCP port. The socket is usually reserved for local connections (SSH into the server and the docker client defaults to using the socket file to talk to the local server) or SSH tunnels, which are not something that works out of the box on Windows (maybe if you try the Windows Subsystem for Linux on Windows 10).
The other connection option is TCP, which isn't enabled on the server out of the box for security reasons. It has no authentication when enabled, so you'll want to use TLS to authenticate remotely, so Docker has steps for that. It's not a 3 min solution, so many look for an easier route to solve this problem.
The easier option for enabling TLS and the TCP port on the server is to use Docker Cloud with the "Bring Your Own Swarm" feature, which manages the certificates and security for you.

docker visual studio ip address issues with .net core

I am very new to Docker. And I created an empty .net core website with docker support. (Visual Studio 17 adds docker support files to the solution and you can run debug etc.)
Everything is ok... then when I run my website, it always opens in a different IP Address: for example http://172.20.52.{{random.ip.here}}/
Now I need to be able to open it in http://localhost:5000
But when I try to map the port 5000:80
Every tutorial I found states that all you need to do is map the port of your host to the container. At this point could it be an issue with my container network.
More information:
I am using Docker for Windows, with a windows host.
my networks on docker:
If you want to do http://localhost:5000, the host port 5000 needs to map to container port 80. But in your container list screen shot, it's the host port 8028 mapping to container port 80. I think you should do http://localhost:8028 instead.

Golang websocket server on docker container won't send out message to outside world

I have a golang backend, node frontend. And it worked both on windows and ubuntu without docker. Now I am trying to dockerize everything. I put both backend and frontend in the same docker container. I can establish initial connection but later the backend kept throwing error like this:
I have exposed port 8000 to 8004, the ws port is 8000 and frontend port is 8004. I have tried both --net=host as well as exposing everything as host ip address 192.168.1.4. Non of them worked.
On the browser side, the websocket client always get 101 response like this:
I think it could be a config problem on docker. But I have no lead right now on how to deal with this. The browser tested is Chrome 55 on windows 10. Docker, golang and node are of the latest. The host machine is on Ubuntu 16.10 as well as container os.

Resources