-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Docker on Windows fails to resolve localhost, causing heath check to fail #9764
Comments
Thanks for the detailed reproduction steps! Interestingly, following them I didn't end up with the same result.
I also happen to have an
I'm running on a Linux host though. It appears as if this is a problem with Docker on Windows specifically, and even One solution may be to run docker using the WSL2 backend instead: nforgeio/neonKUBE#968. I'm also not sure whether querying |
Unfortunately MS hasn't graced Windows Server 2019 with WSL2 yet, and it may just not come until the next LTSC release 🙃. I do think this is an image specific issue though, as my other linux images exhibit different behavior, which is think is because they generate a hosts file allowing them to resolve "localhost"
The above is what I get for those other images, only this one seems to be different.
|
Oh interesting, so it's not an issue with loopback, but rather just DNS. In that case we can just update the check to look at |
(though I do wonder whether the lack of |
@brendan-mccoy Does resolving |
Nope, I can't seem to get that nor "extra_hosts" working. Probably a limitation on windows. In any case, a "fix" (if you call making stuff work on windows a fix ;) ) would be for the container to have the a hosts file prepopulated with the localhost entry, or I guess to change the health check to not use a name. It looks like any alpine based images I've used have the hosts file prefilled, and the debian/ubuntu based ones don't. |
Anyway, I decided just to make a linux vm to run docker in. Maybe when WSL2 is on an LTSC release of Windows Server I'll try again. No clue why it is that the hosts file only seems to not get populated when running on LCOW, I guess that's to be expected with an experimental and no longer developed solution ;). Not sure the root cause of why this happens, but if somebody trying to run this stuff on a windows docker host comes by this, they'll know what's going on. I leave it to the maintainers to figure out what to do with this issue. |
@brendan-mccoy thanks for your responses. It looks like alpine do specifically add in an /etc/hosts file to their images, while Debian and Ubuntu do not (see the linked tar files' contents). Note that our image is based on I'm wary of changing the healthcheck as it's just a band-aid on the root problem. We assume that I've created an issue in debian's image issue tracker to see if they can include |
Upstream (debian docker images) has stated that they indeed don't intend to add an They also helpfully pointed towards Docker's response on the matter, which boils down to "this is still considered experimental and probably will stay that way". With those responses from upstream, there's not much we can do I'm afraid. Workarounds involve switching to a different engine, or perhaps adding an |
Context is in #9764 (comment). I struggled to find a more official link for this. The problem occurs when using WSL1 instead of WSL2, which some Windows platforms (at least Server 2019) still don't have. Docker have updated their documentation to paint a much happier picture now given WSL2's support. The last sentence here can probably be removed once WSL1 is no longer around... though that will likely not be for a very long time.
Description
I'm playing around with the latest docker image, and it keeps throwing a message that it is in an unhealthy state. I checked and it seems that this is because the configured health check is "curl -fSs http://localhost:8008/health || exit 1" and the /etc/hosts file dosen't exist and so localhost isn't able to be resolved. At the time of this posting the image has sha256:d0bca6bb6f4009297601c06a8e3c22e193fde993290e969677b3b30e70bc3286
Steps to reproduce
The health check fails, "curl: (6) Could not resolve host: localhost", the file "/etc/hosts" doesn't exist causing this.
Version information
Version: {"server_version":"1.31.0","python_version":"3.8.9"}
Install method: Docker 20.10.0
The text was updated successfully, but these errors were encountered: