Unable to connect localhost using HyperV Container on Win10 1903 - docker

I was just upgraded to Windows 10 1903 from 1809, then my docker become a little bit weird. Here are my current situation:
OS: Microsoft Windows [ver 10.0.18362.116]
Hyper-V: Installed. I have only one VSwitch called Default Switch.
I reinstalled Docker Desktop for Windows v2.0.0.3. (Docker version 18.09.2, build 6247962)
The docker can run without problem. Only the network issue!
Here is what I tried:
Run iis container in "process" isolation mode.
docker run -d --rm -p 80:80 --isolation process mcr.microsoft.com/windows/servercore/iis:windowsservercore-1903
I can connect to port 80 through localhost.
Run iis container in "hyperv" isolation mode.
docker run -d --rm -p 80:80 --isolation hyperv mcr.microsoft.com/windows/servercore/iis:windowsservercore-1903
I can't connect to port 80 through localhost. I was okay before I upgrade to Windows 10 1903.
I almost tried everything I can try. I just can't get my localhost (loopback interface) works.
I tried on the other machine. When docker started, there is a nat VSwitch will be created by docker. It doesn't work on my machine.
I tried to create a new VMSwitch and named nat but doesn't works.
I tried to run .\WindowsContainerNetworking-LoggingAndCleanupAide.ps1 -Cleanup -ForceDeleteAllSwitches using this script. Restart the computer. It doesn't works.
I completely removed Hyper-V and Docker. Reinstall again doesn't works.
I tried to list networks defined in hnsdiag. (hnsdiag list networks) Then deleted the nat network. Restart the HNS service. Restart Docker again. It doesn't work.
May I ask what else I can do for my docker network settings?

Related

Switching from Docker Desktop to Colima - no localhost access

Trying to switch to colima from Docker Desktop on mac but having issues reaching my containers on localhost.
Removed Docker Desktop and installed colimna/docker w homebrew. Colima starts fine.
I have a command that I use to run Dynamo:
docker run --name dynamodb -d -p 8000:8000 amazon/dynamodb-local"
When I was using Docker Desktop I could reach the database on localhost:8000. Now it's only accessible on 127.0.0.1:8000
My /etc/hosts correctly maps localhost - this is an issue with the switch. Not finding much online regarding this - any ideas? It seems that docker no longer recognizes localhost as an alias for 127.0.0.1 after the switch. Not using Kubernetes or docker compose.

Docker Swarm, Windows Containers, ingress network (Routing Mesh) on Windows Server 2019

I want to build docker swarm cluster on windows. To do this I choose Windows Server 2019 in 1809 Version. I work on my local machine and using Vagrant box vm.box=StefanScherer/windows_2019 I created enviroment for developing purposes.
Set Hostname.
Set private network (192.168.52.100)
Install Docker-EE
On this Windows I have installed docker-ee by using command Install-Package Docker -ProviderName DockerMsftProvider -RequiredVersion 19.03 -Force, and docker work perfectly.
docker version return everething ok
docker run -it --rm -p 8000:80 --name aspnetcore_sample mcr.microsoft.com/dotnet/core/samples:aspnetapp -> also work perfectly.
My first issue is when I perform command docker swarm init --advertise-addr=192.168.52.100 I notice my internet connection is lost for a while (also init/join/leave).
And the secound issue is routing mesh, it is not working
Steps to reproduce:
docker service create --publish published=8050,target=80,mode=ingress --name aspnetcore_sample mcr.microsoft.com/dotnet/core/samples:aspnetapp
Open web browser http://127.0.0.1:8050/ (on machine where I init swarm)
Now I should have access to this sample app under 8050 port. But http://127.0.0.1:8050/ is not working
I know I can use mode=host but I think mode=ingress should work.
I also checked it with the same commands on linux and it works without any problem
How can I resolve this issue?

Windows container BSOD its host

We have been using windows containers as test rigs for while now with great success. However since the last windows update, the container seems it crashes the host system (Windows Server 2019 std).
The server will be running fine for hours, then minutes after executing one of these commands it will crash.
docker run -it --rm -p 8000:80 --name core_sample mcr.microsoft.com/dotnet/core/samples:aspnetapp
docker run --name test mcr.microsoft.com/windows/nanoserver:1809
Just wondering if anybody else is experiencing the same? We already tried to reinstall the host but no joy.
Going on #cael-ras idea of trying a Ubuntu container, I installed HyverV and is now running my containers in Hyper-V isolation mode (--isolation=hyperv) instead of process mode. That seems to have fixed the issue. Thanks
https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/hyperv-container

Docker container ports are exposed on Windows but not Ubuntu

I'm developing an Ubuntu based docker image on a windows 10 machine with Docker Desktop. The image has a server app listening for HTTP traffic on port 5000. When I run the image locally on Windows using:
docker run -d -p 5000:5000 dockerImageName /opt/serverApp
Everything works fine, I can go to http://localhost:5000 and see a web interface.
But then I push the image to a repo in Azure then pull it back down onto a Ubuntu Azure VM and execute the same command, the container appears to start correctly but executing:
curl http://localhost:5000
returns:
curl: (7) Failed to connect to localhost port 5000: Connection refused
Not that it should matter but I've also allowed incoming traffic on port 5000 in the network security group the VM is attached to.
If I execute:
sudo lsof -i:5000
Nothing is returned.
Is this an Azure related issue? Are there differences between how a Linux image is run on Windows and a VM on Azure (on Windows Docker Desktop uses a Linux VM to run containers)?
Le sigh it was this:
Docker container will automatically stop after “docker run -d”
Annoying how the behavior changes between Windows and Ubuntu when running containers.

How do I configure docker to allow a connection to a container from other computers?

I am trying to run a small test server with MS SQL Server running on a Mac in a Linux docker container. Maybe I have the terminology wrong so please correct me if necessary:
host - the macOS desktop with docker installed (ip 10.0.1.73)
container - the Linux instance running in the docker container with SQL Server running in it
remote desktop - another computer on the local area network trying to connect to SQL Server
I followed the MS installation instructions and everything seems to be running fine, except I can't connect to SQL Server from the Remote Desktop
I can connect to the docker host(10.0.1.73) and can ping the IP address
I can connect to SQL Server from the docker host and see the databases etc.
I used the following command to create the docker container
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<XXXXXX>" -p 1433:1433 --name sqlserver1 -d microsoft/mssql-server-linux:2017-latest
Thinking that the -p 1433:1433 would map the linux port to the macOS host port and allow the remote computer to access the docker container when connecting to that port on the macOS host from the local area network
This is not working and I assume this may be to do with the network routing on the macOS host
Most solutions I have seen seem to indicate that one should use the VirtualBox UI to modify the network settings - but I don't have that installed
The others seem to have pages and pages of command line instructions that are required
Is there an easy solution somewhere I have missed?
EDIT:
Some more research and I found this explanation about how by default the Docker networking is set up for single host networking. Good explanation for anyone else struggling with the Docker concepts.
It is also worth reading up about the differences between docker containers and virtual machines...
https://youtu.be/Js_140tDlVI
Still trying to find some explanation on multi host networking.
try disabeling the firewall on the host you want to connect to.
port 1433 will be forwarded to the docker container, but your host (MAC) should have port 1433 open to be able to connect to your host.
Using NAT:
Assign the target address to your host interface:
sudo ifconfig en1 alias 10.0.1.74/21 up
Create the docker container and map the port to the second IP address assigned to the host interface
sudo docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<XXXXXXXXX>" -p 10.0.1.74:1433:1433 --name sqlserver1 -d microsoft/mssql-server-linux:2017-latest

Resources