-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Internal Host DNS cannot be resolved (Windows Container 1803) #1976
Comments
Hi @4xiz |
It's a windows daemon limitation and needs to be fix there but we will add a workaround waiting MS to fix it upstream. |
Release 18.05.0-ce-win66 works. Thanks. |
@atomaras |
I just tried this and it isn't working for me. Version info: Windows Docker
Ping output:
|
@JoshCollinsMSFT I have the same windows build (17134.112) and docker (18.05.0-ce) and am also not able to resolve host.docker.internal. No joy with connection strings. |
Still not working for me with 18.06.0-ce:
|
Same problem. |
So it seems the way this was fixed is that it must write out to the local hosts file on the host machine. I have a bit of a situation as Symantec Endpoint blocks write access to the hosts file :(. |
They are 2 separate things. First, for dockerd to get Second, in the windows containers, we do a docker exec as soon as the container is started (using docker event) to patch the hosts file in the container (I don't know what happened if you are running in process isolation, because we don't support Windows server). So if you overwrite it at runtime you can lose those entries. @Heurazio this is @prochnowc can you try |
@ebriney Interestingly ... if i wait 2 seconds after startup i can ping |
Unfortunately it does not work.. Does the |
@prochnowc, we execute that script as soon as we receive the start event from any windows containers:
Perhaps the hosts file doesn't exist and there is an exception reading it. |
@ebriney Am I right when saying that this requires working PowerShell in the windows container? My traefik container does not have PowerShell. |
@prochnowc Arfff, that's why it didn't work. Do you have a suggestion on how to solve that? |
@ebriney So actually this fix only works on windows containers which have PowerShell installed (which is not the case for windows nanoserver). I dont think the hosts file editing can be done with "standard" windows command line utils. My idea would be to implement this in the docker DNS. |
@prochnowc hummm, nanoserver includes powershell (see command line above). |
@ebriney Sorry, but nanoserver does not include PowerShell by default. See https://docs.microsoft.com/en-us/windows-server/get-started/nano-in-semi-annual-channel. Your command line didnt work with pure nanoserver image. I had to use |
and so why |
ok that's in 1803 image |
@ebriney , Would you be able to update your powershell script slightly to only write to the host file if needed? I can see you do an if string contains "host.docker.internal" but then also add the comment strings to the file after the check by the looks of it. Because of this second write to the file outside of this condition, this one is causing me a bit of pain because I've had my I.T update my hosts file manually to fix this, but because of this second write statement that happens unconditionally, when I click switch to Windows containers, there is a "can't write to hosts file error" still and crashes Docker. Also in my case the wrong host ip was getting selected too as we have multiple network adaptors. A suggestion if you could make if possible, would be to first check the DNS resolves first, if it doesn't then check if the hosts file has the additions it needs, and write to it if its not in there, also would move the second write in to the if statement. Hope this makes sense. I've coded and tested my suggestions above (W10) in the below, so feel free to use parts or all of it if needed:
|
Issues go stale after 90 days of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
/remove-lifecycle stale |
Still getting this issue, my containers (same images) randomly fail on startup. sometimes they start, sometimes they hang in "created" state and application log filled with repeated errors like below. I am running windows containers on windows 10 surface book laptop, calling docker run from PowerShell ISE elevated (running as admin) and still hit this issue at least 50% of the time, without changing anything in my images:
|
Is anyone looking into the root cause of this? |
/remove-lifecycle stale |
Docker 3.3.3 Same issue |
Updated to Docker Desktop 3.3.3 a few days ago, and this issue seems to have crop up again (hostname |
I am on Docker 3.3.3 and I also am seeing this issue - anyone know a specific version of Docker where it actually did work? |
I am on "Docker version 20.10.6, build 370c289" and have the same problem. I've used @brunnotelma 's workaround successfully, thanks for that! |
If I use https://docs.docker.com/docker-for-windows/release-notes/#docker-desktop-community-2501 with docker.for.win.localhost or host.docker.internal I see the same issues - @brunnotelma's workaround did not fix this issue with Docker 3.x either. I am tracking this issue with reproducible images here: envoyproxy/envoy#16710 in case it is of interest to the Docker team |
I found a workaround. |
Thank You! |
Issues go stale after 90 days of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so. Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. |
/lifecycle frozen |
/remove-lifecycle stale |
/remove-lifecycle stale |
@brunnotelma apologies since this is an old comment, but would you be able to let me know which image you were able to get this script to work on? I'm trying to run your startup script on a
This is the gist of my Dockerfile (some irrelevant details removed):
I've tried granting the ContainerUser full access to that directory, but I'm unable to as I get
My Docker engine is |
Hi @hasibr, as far as I remember, the default user for Windows images is always "ContainerAdministrator". I have many containers running this startup script off of these base images:
Just wondering: why do you need to change your user to |
Hi @brunnotelma , thanks for the tip. I changed to the However, I'm still unable to ping
Also the reason I used
I suppose there is no issue using |
Expected behavior
According to the Docs host.docker.internal resolves the host's ip.
Actual behavior
Ping request could not find host host.docker.internal
Network works fine. Pinging Host IP directly (ipconfig) works as expected.
Host: Windows 10 Enterprise
Container: microsoft/windowsservercore:latest
Neither stable (18.03) nor edge (18.04) works.
Probably important side note: DNS can be resolved in Linux Container (Ubuntu)
The text was updated successfully, but these errors were encountered: