Settings to Windows Firewall to allow Docker for Windows to share drive - docker

Windows Firewall is blocking my attempt to allows Docker for Windows to share C: on windows 10 machine.
Works fine when Windows Firewall off. When its on I get
A firewall is blocking file Sharing between Windows and the
containers. See documentation for more info.
The documentation says
You do not need to open port 445 on any other network. By default,
allow connections to 10.0.75.1 port 445 (the Windows host) from
10.0.75.2 (the virtual machine).
I am "googled out" on trying to find how to do that - can someone advise?

You don't actually need to share the C drive but only reinstall (or potentially even uncheck - click OK - then check) the File and Print sharing service on the Hyper-V virtual network card.
See this article.
Also if there are restrictions on your network profiles (i.e. public), consider changing the default "unidentified network" for the "vEthernet (DockerNAT)" card to private via this PowerShell command before doing the above:
Set-NetConnectionProfile -interfacealias "vEthernet (DockerNAT)" -NetworkCategory Private

Ok, so after running in the same issue,
I have found a Solution.
This is what I did:
Step 1:
Open ESET. Then click on Setup
Step 2:
Click on Network protection
Step 3:
Click on Troubleshooting wizard
Step 4:
Find the Communication 10.0.75.2 (Default docker IP setting)
Just check what the IP Range is defined inside your docker settings. Then look for for the IP which resides in that range.
Step 5:
Click on the Unblock button, then you should receive this screen.
This solved the issue for myself.
You can then go to the Rules and check the rule that was added.
PS: This is my first post, sorry for any incorrect procedures.

Only this solution helps me:
Go to Hyper-V Manager -> Virtual Switch Manager -> DockerNAT -> Connection Type: change from internal to private, apply, change back to internal, apply
Restart MobyLinuxVM
Restart Docker
Set Docker network profile to 'Private'. Run command in PowerShell as admin
Set-NetConnectionProfile -interfacealias "vEthernet (DockerNAT)" -NetworkCategory Private
Reset File and Printer Sharing for Microsoft Networks on DockerNAT connection
Go to Docker -> Settings -> Shared Drives and share C:

My solution was to disconnect from the VPN; that was causing the issue

I was not using any third party firewalls when running into this error. I was convinced it was a Windows Firewall issue, though disabling Windows Firewall did not work for me. I finally found this blog post after much research: Docker on windows 10 error: A firewall is blocking file Sharing ...
It ended up NOT having to do with the built in Windows Firewall.
The Fix
Uncheck File and Printer Sharing for Microsoft Networks from the vEthernet (DockerNAT) network adapter (you can find the connection in the Windows Network and Sharing Center).
Recheck it and make sure it is enabled.

My C drive stopped being shared with Docker after a recent Windows 10 update. I was getting the same problem saying it was blocked by the Windows firewall when attempting to reshare it.
Looking through the above solutions, I found something that worked for me that is simpler than anything else I saw on this page. In Control Panel\All Control Panel Items\Network and Sharing Center, on the vEthernet (DockerNAT) connection, I unchecked the property File and Printer Sharing for Microsoft Networks and saved the setting. Then I checked the property again to reenable it and saved it again.
At this point, I was able to reshare the C drive in Docker settings. I have no idea why this worked but it was not a firewall problem, which already have an entry for DockerSmbMount.

I had this problem with Kaspersky; turning off Kaspersky worked, so I knew it was the firewall. In my case, Kaspersky was already blocking port 445 for some reason. I had to go to Packet Rules for the Firewall, Local Services (TCP) and remove 445 from the list of blocks ports.

For Windows 10 machines on domain networks, when creating the Hyper-V virtual Ethernet adapter, it gets categorized as a public network. You have to change it to a private network to allow the more relaxed Windows Firewall rules, and therefore allow file sharing.
Run the following command in PowerShell:
Set-NetConnectionProfile -interfacealias "vEthernet (DockerNAT)" -NetworkCategory Private
Change the name in quotes if your machine's virtual Hyper-V network connection is called something else.

My problem was Cisco Anyconnect VPN interfered with internal docker networking
to fix this go to:
Cisco Anyconnect Settings > Preferences >
check Allow local (LAN) access when using VPN

As stated in one other answer Docker doesn't play nice with a VPN.
If you're using Nordvpn you have to disable "Invisibility on LAN" and probably "Internet Kill Switch".
If you've done so it should work even with the VPN active.

That depends on what firewall do you have installed. In my case I do have disabled the built-in Windows Firewall and I am using ESET Smart Security so my rules looks like:
Create a rule for IN connection since you should allow Docker to connect to your host and set it to Allow
Setup the port properly as explained in docs meaning 445:
Setup the remote IP address:
Maybe this is not the answer since it's not related to Windows Firewall but could give you a clue in what to do.

In my case, I disabled "Block TCP 445" on Windows Defender Firewall with Advanced Security and it worked. Then enabled it again after setting shared drives on Docker.

None of the above worked for me.
What finally did the trick was opening the properties of the "vEthernet (DockerNAT)" network and ticking the box "Hyper-V Extensible Virtual Switch" at the bottom of the list under the "Networking" tab.
Not sure if this is the actual fix or whether it just somehow reset the network adapter for me... but it worked!

Seem like many having this issue when running Cisco AnyConnect. I got the same problem and here is how I solved:
The cause: The subnet being used by Docker is in the list of Secured Routes managed by Cisco AnyConnect (I believe this list is managed by your VPN's admin).
The solution: Change the subnet used by Docker to not overlap with the list being managed by AnyConnect.
For example, in my case, I changed from 10.0.75.0 (which was overlapped with 10.0.0.0/8) to 172.31.0.0/28.

I had the same problem and tried all the fixes - and it turned out that more than one was necessary:
Add a firewall rule (Norton Security for me)
Make the network private
Share the drive
I've written a full explanation at http://kajabity.com/2017/08/unblock-docker-for-windows-firewall-issues-with-host-volumes/

My G drive stopped being shared with Docker after a recent Windows 10 update. I was getting the same problem saying it was blocked by the Windows firewall when attempting to reshare it.
Then I had tried to solve this issues by couple of suggestion but i cant resolve that issue after that I have tried to Reset credentials below of Shared Drives and my issue was solved.
So If you want then you can try to do this-

Everything everyone posted DID NOT WORK for me.
THIS DID.
I installed the EDGE release. I then went to WINDOWS DEFENDER and disabled the firewall for DOCKER NAT. (not my actual ethernet adapter, just the docker nat)
Once I disabled windows defender/firewall THAT way it worked fine.
ugh. really hopes that helps some of you!

Even after ensuring that the inbound firewall rule is set up properly and even after uninstalling and reinstalling the File and Printing Sharing Service it didn't work for me.
Solution: on top of that I also had to do a third thing. I had to deactivate the checkbox Prevent incoming connections when on a public network in the specific firewall settings for public networks. After doing that it started working for me as well. See screenshots attached at the end of this message.
Don't know how long this option has been there already. I'm currently working on Win 10 Pro 1709 16299.402.
1. Open specific firewall settings for public networks
2. Uncheck this checkbox

I had same issue with F-secure, DeepGuard was blocking the Docker service. My solution was:
Open F-secure client and click "Tasks"
Choose "Allow a program to start"
Choose from list "com.docker.service" and press "Remove"
After that restart Docker client and try to apply for file share.
Also very good troubleshoot guide here: Error: A firewall is blocking file sharing between Windows and the containers

I had the same problem with firewall not allowing me to share my C drive. I tried all listed above solutions and nothing worked for me. Then I uninstalled docker completely from my machine Control Panel\Programs\Programs and Features ->
select Docker for Windows -> Uninstall
Then go to docker website and click Get Docker for Windows (Stable)
After that I was able to share drive C

For AVG Internet Security, enabling Internet Connection Sharing Mode under the Firewall settings did the trick for me.

Using Kaspersky Internet Security you can resolve this easily if you change the vEthernet (DockerNAT) network adapter type to Trusted network.
Settings > Protection > Firewall > Networks > vEthernet (DockerNAT) > Select "Trusted Network"

In short, use the Edge version.
The Edge version of Docker for Windows since 2.1.5.0 (2019-11-04) has a new implementation of file sharing without requiring firewall modifications
https://docs.docker.com/docker-for-windows/edge-release-notes/
"New file sharing implementation: Docker Desktop introduces a new file sharing implementation which uses gRPC, FUSE, and Hypervisor sockets instead of Samba, CIFS, and Hyper-V networking. The new implementation offers improved I/O performance. Additionally, when using the new file system:
Users don’t have to expose the Samba port, and therefore do not experience issues related to IT firewall or the drive-sharing policy.
There is no need to provide user credentials to Docker Desktop. File access rights are automatically enforced when accessing mounted folders through containers.
"
You can download the edge version: https://download.docker.com/win/edge/Docker%20Desktop%20Installer.exe
Note as of now, the edge version of 2.1.7.0 will be used for next stable release: "Note: Docker Desktop Edge 2.1.7.0 is the release candidate for the upcoming major Stable release.". So the risk of using Edge is relatively low. Or you can wait for next stable release, to avoid all these firewall issues.

25 Jan 2020
It seems, it is an issue in the old versions, I installed the last version :
Docker version 19.03.5, build 633a0ea
and it worked for me without any configuration.

This (link below) seems to be the best fix i have found so far. It is persistant across reboots. It is best explained here: https://gist.github.com/biggyspender/8b5b2ed9ff63de31045d41304e3915b3
The vEthernet network interface seems to be dynamically created each time the system is started, and it is created in the 'Public' group as opposed to in the 'Private' group (where it works). The edits in one of the Docker startup scripts (called out in the link above) automate the powershell command / fix noted by David Tesar above....
I had more luck adding the function to the script as opposed to editing the script and changing 'Internal' to 'Private'.

If non of the above works, just make sure you're not connected to a VPN. That's exactly what happened to me, i was connected to a VPN using Cisco AnyConnect client, also make sure you set an static DNS in the docker settings.

I tried everything listed here and on https://github.com/docker/for-win/issues/360
Nothing worked for me.
I run my dev environment on a docker container, and while on Corporate VPN (Cisco AnyConnect), I need the to mount my local drive on the container to access my project files.
Here's a docker hack that worked for me. Add --publish 8000:8000 to your existing docker run command.
So
docker run -v C:/Users/kumar.joshi/KumarData:/mnt --name dev <image:latest>
will become
docker run -v C:/Users/kumar.joshi/KumarData:/mnt --name dev --publish 8000:8000 <image:latest>
Make sure the port is not used else you will get this error:
Bind for 0.0.0.0:8000 failed: port is already allocated

for those who can not solve this issue by any means, you can try this: manually map drive into the docker host:
https://github.com/docker/for-win/issues/466#issuecomment-416682825
The research is here: https://github.com/docker/for-win/issues/466#issuecomment-398305463

I found it quite easy. Just go to you network connections. You can go Control Panel/Network and Sharing. You will find various connections. Search for Docker connection. Select which ever is default. After selecting network, go to Properties. In the properties section enable the option Hyper-V Extensible Virtual Switch. This will help virtual container to use network card.

What did it for me (after several hours of trial-n-error) was changing the Subnet Mask from 255.255.255.240 to 255.255.255.0 (which should not change anything).
As part of the trial-n-error, I had done everything else listed on article, but without any success .. but this last step did it .. and reverting back to 255.255.255.240 does not break the good cycle.
I admit, it makes no sense .. but it might be related to an internal state only being triggered by the network change.
Anyway, if i have helped just one, then it was worth the effort.
Docker Desktop edge, 2.0.4.1 (34207)

Related

Access to internal infrastructure from Kubernetes

If I run Docker (Docker for Desktop, 2.0.0.3 on Windows 10), then access to internal infrastructure and containers is fine. I can easily do
docker pull internal.registry:5005/container:latest
But ones I enable Kubernetes there, I completely lose an access to internal infrastructure and [Errno 113] Host is unreachable in Kubernetes itself or connect: no route to host from Docker appears.
I have tried several ways, including switching of NAT from DockerNAT to Default Switch. That one doesn't work without restart and restart changes it back to DockerNAT, so, no luck here. This option also seems not to work.
let's start from the basics form the official documentation:
Please make sure you meet all the prerequisites and all other instructions were met.
Also you can use this guide. It has more info with details pointing to what might have gone wrong in your case.
If the above won't help, there are few other things to consider:
In case you are using a virtual machine, make sure that the IP you are referring to is the one of the docker-engines’ host and not the one on which the client is running.
Try to add tmpnginx in docker-compose.
Try to delete the pki directory in C:\programdata\DockerDesktop (first stop Docker, delete the dir and than start Docker). The directory will be recreated and k8s-app=kube-dns labels should work fine.
Please let me know if that helped.

"VirtualBox is configured with multiple host-only adapters with the same IP" when starting docker

I am trying to run Docker on an old Mac OS.
I get this error:
Error setting up host only network on machine start: VirtualBox is configured with multiple host-only adapters with the same IP "192.168.99.1". Please remove one
The issue came from having run docker on two different sessions on my machine.
To fix it I ran: VBoxManage list -l hostonlyifs to identify adapters, and then removed the one I didn't need anymore:
VBoxManage hostonlyif remove vboxnet1
Alternatively, if you want to be able to run Docker from two different sessions, you can change the IP address of each adapter:
Go to File -> Host Network Manager
Change the IP address of one of the adapters
I had this same issue come up as well when using Local by Flywheel.
I have two different user accounts on my Mac. One for personal, one for work. I was still logged in to my work account when trying to start up a machine on my personal account.
After making sure I was completely logged out of my work account and restarted, I was able to get it working again on my personal account.
Before doing this I noticed that my IPv4 Address/Mask under Host Network Manager was the same. After having logged out and restarted, it is now different and I no longer am getting the notice when starting Local by Flywheel.
Hope this helps someone out!
This Error happens because you have already virtualbox installed in your computer.
Here is the simple step.
Step 1: Uninstall Virtualbox from Your Computer
Steps 2: Uninstall Docker and Re-Install It
Fixed!!!

Docker windows container DNS Cache and firewall

I have a Docker windows container and Linux container on a different node.
On windows, I opened ports in the firewall mentioned here: https://docs.docker.com/network/overlay/#operations-for-all-overlay-networks
(8 rules - 4 for in and 4 for out) but even then when I connect to the container on the windows host and try to ping the Linux container I receive "No such host is known" but after executing (inside the container):
Clear-DnsClientCache
everything starts to work.
I also removed the whole stack and tried to disable firewall and surprise - now everything works without clearing the DNS cache.
Once again I removed the stack and enabled the firewall - again I have to connect to the container and clear the cache to make it work.
Looks like there is something wrong in the firewall settings but what? I did not find any other ports which should be opened
Looks like I have just found an answer but I do not fully understand it. I have tried to open ports first 0-9999 then 0-5000 then 0-2500 etc and found out that I need to open port 1888 (tcp, in) to make the docker overlay network work immediately (I mean to be able to resolve services DNS names immediately) but I did not find anything about that on the internet. I have no idea why. Was I only one with that problem? Maybe this is not the correct solution? Could someone tell me why this port is needed and why Clear-DnsClientCache works even when 1888 is blocked?
Edit:
Looks like this solution was wrong. Now it just works once and then does not work and then once again works. I can remove and recreate the whole stack and it just works randomly.

docker error in windows container read tcp : wsarecv: An existing connection was forcibly closed by the remote host

i am using the latest version of docker for windows. the linux container goes smoothly but i am getting below problem
wsarecv: An existing connection was forcibly closed by the remote host.
it occurs for fetching some specific image from repos. In my case i am fetching microsoft/aspnet. i have created a docker file and trying to built my custom image.I have followed the repository instruction for creating a docker file.
the picture is given below
after this state i am getting this forcibly closed by remote host error.
my dockerfile content is
FROM microsoft/aspnet:4.7
ARG site_root=.
ADD ${site_root} /inetpub/wwwroot
I am not sure exactly why this one worked, as I was trying to do a pull of a couple microsoft images. But in Settings > General > Expose daemon on tcp://localhost:2375 without TLS, worked for me. Following that I reverted the change but nice to have that on in the back-pocket. Might be related to firewall settings in Windows. I am using Win 10 Professional.
I had been consistently encountering this error from inside a corporate network. We added mcr.microsoft.com to a firewall white-list, and everything worked as intended.
To Debug:
Check the blocked connections.
Try unblock internet on the machine, before you whitelist the urls one by one.
Allow the below urls- from windows firewall, any corp proxies, corp firewall
"*.docker.io"
"*.docker.com"
"*.microsoft.com" - windows update dependencies for windows containers
"*.mscr.io" -again for microsoft container registries
Worked in my case. Could be more to whitelist, depending on what you are trying to pull.

Windows 10 Docker Network DNS doesn't work after reboot

I'm not sure if this is an issue with the current version of Windows Docker network or poor configuration and misunderstanding on my part, but I have the following setup:
2 Docker containers (built using the Microsoft/ASP.NET image as a base) running a .NET MVC application in each.
1 Docker container running SQL server (built using the Microsoft/mssql-server-windows image)
When I create all 3 containers everything works great, I can attach and ping all other the other containers using their names without any issue. The applications run and can communicate with each other as I hoped.
However, when I reboot my machine and start all the containers again they can no longer ping/communicate with each other using their names (using IP addresses is fine).
I've tried this on the default NAT network and also tried replacing the NAT network with my own custom NAT network.
To resolve the issue I have to run the force network disconnect command for each container as such:
docker network disconnect nat <containername> --force
And then I have to reconnect each container to the network before starting them up. All containers can then ping/communicate with each other using their names as well as their IP addresses.
FYI, this is a development environment but I was hoping to do something similar in Azure using a Windows Server 2016 VM, although I don't quite know what the best network configuration is for live production yet as I need to have multiple applications (in separate containers) on the same node accessed via their own subdomains.
Any help or guidance would be great.
I'm not sure, in part because this question was asked several months before any other example I've run into, but this sounds very similar to the problem described at https://github.com/docker/for-win/issues/1038.
Basically, there appears to be a problem introduced with the 1709 update to Windows 10 which results in a scenario where Hyper-V networking doesn't work the way it ought to.
There appear to be two common ways of working around this problem: Turning off "Fast Start" in the Control Panel => Power Options => System Settings, or restarting Docker for Windows and any containers after booting. I also thought I saw something on a Microsoft blog post indicating that the underlying problem has now been resolved and will be included in an update to Windows 10, but alas I can no longer find that information or the specific version number in which the problem was (theoretically) resolved. It may well be the delayed 1803 "Spring Creators Update" release.

Resources