Missing DockerNAT after upgrading to Docker Desktop 2.2.0 on Windows
After updating my local Docker Desktop from 2.1.0.5 to 2.2.0 i was unable to use the IP 10.0.75.1.
After some investigations, i found that the entire definition of "DockerNAT" disappeared.
I searched google for possible solutions but i didn't find anything useful.
I tried to delete and reinstall the 2.2.0 version but without success.
Through the page https://docs.docker.com/docker-for-windows/release-notes/ i was able to retrieve a functional version of the latest 2.1.0.5; once installed all started to work as before. The output of the ipconfig command is:
`
Ethernet card vEthernet (DockerNAT): Connection specific DNS suffix: IPv4 Address. . . . . . . . . . . . : 10.0.75.1 Subnet mask . . . . . . . . . . . . . : 255.255.255.240 Default gateway . . . . . . . . . : ` This is the part that was missing with the new installation.
Yep. They did that. I am already updated and lose DockerNAT too.
We deliberately removed the DockerNAT in the latest version because it's no longer necessary due to our new filesharing implementation.
There are existing, much more suitable methods for doing everything around this network adapter, can you perhaps describe why you want to use this IP and I can point you to a good solution?
Thanks for the fast replay.
At the moment i am using the 10.0.75.1 IP address as convenient way to address my machine both by the browser (running in the host) and the internal services (running inside the docker network).
I modified the "hosts" file to be able to use a DNS-like name and since i am still in development phase it is more than sufficient.
I can say that in the final production environment this problem will not arise (i will re-organize my services in a convenient way), but in development, where i have limited resources, it is very convenient to do so.
@mikeparker what are those solutions? The missing DockerNAT is an issue for us as well
@LeonSebastianCoimbra Generally implementing something which allows you to access the host from a container AND use the same mechanism for container-to-container communication is not a best practice, because at scale the system often needs multiple hosts across a cluster, and so the hostname (and IP) will change. Generally for container to container communication we have DNS names provided by docker compose for example.
However, if you're looking for a solution that is 'developer only' (this won't necessarily work in production) and you are trying to standardise a mechanism for talking to containers either from a different container or on the host, you need to use a DNS name (not an IP address) as the DNS name will resolve to different IP addresses inside containers and on the host - we no longer have an IP address accessible by both the host and the container.
We technically provide a DNS name you can use for this purpose: kubernetes.docker.internal this is currently used by, as you can guess, kubernetes, allowing us to share the kube context on the host and inside containers. There is also host.docker.internal which may work depending on what you're trying to do exactly.
If this is something that is required maybe we need to look again at the feature and make it more of a standard feature - any more information on your use case would be useful.
@ChristopherMillon let me know what your use case is and whether it's the same as the above.
Yes. I use it in dev on laptop, make route for bridge docker. Startup dns-proxy-server(http://mageddo.github.io/dns-proxy-server/latest/en/1-getting-started/running-it/) in container. After that DNS record update automaticly form start-up containers. And I can access to any conteiners by DNSname.
I have solution https://www.bountysource.com/issues/39154772-how-to-access-containers-by-internal-ips-172-x-x-x whih disapear after 2.2 update. To access internal container IP's. What is a solution now?
Linux native installation provides access to docker network, why windows should not provide it? But we use route for that and it works. In setting we have:
Hyper-V subnet
10.0.75.0/28
default: 10.0.75.0/28
But fact script what start Hyper-V virtual machine not use it after update.
@mikeparker it's basically the same, we docker inspect ... get the IP Address of the container and then communicate with it from the host for dev/testings purposes.
You recommend using DNS? How would this work exactly? Do we have to set explicit hostnames for our containers and prefix them by host.docker.internal or kubernetes.docker.internal?
@ChristopherMillon that doesn't sound the same. Leon is talking about accessing the host machine. You're talking about accessing a container.
If you want to go host -> container simply expose the port and use localhost.
@straga @bondas83 I don't understand what you're saying.
@mikeparker binding onto the localhost is an issue as in case of CI/CD (or even dev machine) those ports won't necessarily be available.
We're using docker-compose, and ports are pre-defined in the docker-compose.yml
Before it worked with a route going through DockerNAT, and ensure we could run tests in parallel without worrying about used ports.
@ChristopherMillon can you elaborate a bit more: a) why don't you have control over which ports are in use on a CI/CD machine? Usually CI/CD environments are designed to be reproducible. b) You say your ports are pre-defined in your docker-compose file but you also say you can't guarantee which ports you're using, can you clarify? c) When you say tests in parallel are you talking about spinning up the same docker-compose set of services multiple times on the same host for different purposes?
Anything further you could tell me about what you've been doing in the past and why would be helpful, thanks! (including the automation of docker inspect and how that fits into your workflow)
@mikeparker For example a I have 10 services with 8069 port.
- demo1_testdrop.app.dev.local + demo1_testdrop.pg11.db.local
- demo10_report.app.dev.local + demo10_report.app.pg11.db.local ....
- ....
if use port: need 20 diferent ports. Remember them all, keep a list of which where. It looks not good.
@mikeparker
a) Couldn't guarantee a specific port is available on a testing node as another test set might be running as well using the same port (We run sets of tests in parallel).
b) What I meant is because we're using docker-compose, we couldn't be able to say 'use any available port on the host', hence why binding onto the localhost could be unreliable in this case.
c) Multiple docker-compose sets are trying to spawn up the same services, using the same ports for different test sets.
After writing all this, I realised we could do fine with binding onto host, sometimes we might have to manually docker rm in order to free the ports up and remove test sets parallelism.
We got C# test assemblies calling docker-compose, a particular set of tests will spawn up a particular docker compose environment in order to run the tests, and we do like to be able to run those sets of tests in parallel as it makes things faster.
Nice thing about having C# test assemblies doing all this, is the debugging capability in our services.
Those tests assemblies docker-compose up -f somefiles.yml and get all the associated IP Addresses for each container, then we use those IP Addresses (say I want the IP of the kafka1 container) to arrange the environment, act and assert what happened.
@ChristopherMillon if I understand you correct you're running C# tests on the host, and the C# tests themselves trigger docker-compose to spin up containers necessary for the test, then the test runner on the host communicates with those containers? And you're running these tests in parallel and some of them share docker-compose files to spin up infrastructure which would naturally have the containers overlap port-wise?
Where does the DockerNAT come into this? You say get all the associated IP Addresses for each container but this doesnt mention the IP address of the host. Do you need to communicate from the container to the host, or purely from the host to the container? (or both)
I'm happy to go back and forth some more, but I think it's going to be quicker if you can provide a fuller reproduction of the problem you're seeing as it's hard to diagnose like this. Can you describe a set of steps that I can perform to see the exact problem you're having?
@mikeparker However, if you're looking for a solution that is 'developer only' (this won't necessarily work in production) and you are trying to standardise a mechanism for talking to containers either from a different container or on the host, you need to use a DNS name (not an IP address) as the DNS name will resolve to different IP addresses inside containers and on the host - we no longer have an IP address accessible by both the host and the container.
Yes, only for development and yes, emulating it in the "hosts" file (in development i do not have access to a DNS server to do the change) i was using a personal DNS name.
@mikeparker We technically provide a DNS name you can use for this purpose:
kubernetes.docker.internalthis is currently used by, as you can guess, kubernetes, allowing us to share the kube context on the host and inside containers. There is alsohost.docker.internalwhich may work depending on what you're trying to do exactly.
Thanks for the tip, i think that this one can solve my current problem for the development.
@mikeparker If this is something that is required maybe we need to look again at the feature and make it more of a standard feature - any more information on your use case would be useful.
NOTE: this won't solve the case when i need a specific DNS name (different from the one docker provide by default), since the ip addresses pointed by "host.docker.internal" (and similar) is dynamic and changes at each reboot. The convenient part of the 10.0.75.1 was that it was static (always reliable) and gave me the ability to choose the DNS name. If you think that SSL certificates can be involved it is not a bad thing!!
Thanks to your clarifications i think that i my be ok from my side... i let you close this issue as soon as also the others participants are satisfied.
On 2.0.x and 2.1.x I relied on DockerNAT to discover the host IP and let containers (more specifically Linux Containers) communicate with the Windows host. From a Powershell script on 2.0.x and 2.1.x I discovered the host IP using the following code:
$ip=(Get-NetIPConfiguration | Where-Object { $_.InterfaceAlias -eq 'vEthernet (DockerNAT)' }).IPV4Address.IPAddress
On 2.2.x I confirm that Docker NAT is no longer available. The solution, inspired by this discussion, is to rely on docker.for.win.localhost. Basically I spawn a small Alpine container asking it to resolve docker.for.win.localhost. So I changed the Powershell line into the following:
$ip=(docker run --rm alpine sh -c 'getent hosts docker.for.win.localhost | awk ''{ print $1 }''')
Note: it returns a different IP (192.168.xxx.yyy) instead of the usual 10.0.xxx.yyy but I verified that they are equivalent and containers-to-host communication works.
Same here, as soon as i am updated to 2.2.0 DockerNAT is gone. @mikeparker you say this done on purpose? Then i'm really missing a piece now, how can i access running Docker container by it's IP address directly from windows machine? Prior to 2.2.0 this has been achieved via DockerNAT network, i've been adding a route to the routing table, some convenient DNS name in hosts file and accessed running web services within my container, or DB... Now, with DockerNAT gone, none of that work... do i miss something and there is another way to achieve the same behavior?
I logged the same issue with another bug https://github.com/docker/for-win/issues/5560 (sorry, I've now closed that).
But as I say there, it would've been super nice to have a clear 'breaking changes' notification in this release, as it was removed on purpose 😄
... sorry to be that guy: https://xkcd.com/1172/