I’m running Windows containers on Docker for Windows. My
docker-compose.yml looks like this:
version: '2.4' services: web: image: microsoft/aspnet platform: windows networks: webnet: ipv4_address: 184.108.40.206 ports: - "4119:80" expose: - "80" dns: - 220.127.116.11 - 18.104.22.168 networks: webnet: name: "custom_network" ipam: config: - subnet: 22.214.171.124/16 gateway: 126.96.36.199
When I attach PowerShell and run
ping 188.8.131.52 the ping goes fine. But when I run ping a domain name I have the following result:
PS C:> ping google.com Ping request could not find host google.com. Please check the name and try again.
And it’s the same for any other IPs/domains.
So my container has an access to Internet, but it cannot resolve domain names.
As a workaround, I’ve tried to inject pre filled
hosts file into container and then ping by domains from that file works fine. It resolves IP address correctly and receives replies from remote machine.
What did I miss? How should I configure Docker containers to solve this issue?
I have the following Docker version on my PC:
> docker version Client: Docker Engine - Community Version: 19.03.2 API version: 1.40 Go version: go1.12.8 Git commit: 6a30dfc Built: Thu Aug 29 05:26:49 2019 OS/Arch: windows/amd64 Experimental: true Server: Docker Engine - Community Engine: Version: 19.03.2 API version: 1.40 (minimum version 1.24) Go version: go1.12.8 Git commit: 6a30dfc Built: Thu Aug 29 05:39:49 2019 OS/Arch: windows/amd64 Experimental: true
> docker-compose version docker-compose version 1.24.1, build 4667896b docker-py version: 3.7.3 CPython version: 3.6.8 OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018