Custom docker network disappeared after server 2019 reboot
- [x] I have tried with the latest version of my channel (Stable or Edge)
- [ ] I have uploaded Diagnostics
- Diagnostics ID:
Expected behavior
An created custom docker network will continue to exist after the server is restarted.
Actual behavior
After rebooting the server, both the custom network and the standard docker network (nat) disappeared. Due to this behavior, containers that use the custom network (transparent network) can no longer be started!
Information
- Windows Version: Windows Server 2019 Standard (Desktop)
- Docker for Windows Version: 18.09.0
Steps to reproduce the behavior
- Create a new network (docker network create -d transparent --subnet=192.168.60.0/24 --gateway=192.168.60.1 tlan
- Check networks (docker network ls)
- Reboot Windows Server 2019
- Check networks (docker network ls) --> Networks "nat" and "tlan" disappeared!
I noticed similar behavior. Server installed updates and booted. Docker was unable to restore containers because user created nat network disappeared. I have noticed this behavior on two computers. Docker service restart does not affect user networks, only windows boot.
I am experiencing the same behavior using Docker EE 18.09.1 on Windows Server 2019.
Yes, same for me. What's going on? Docker version 18.09.2.
I have the same problem. Network driver is nat.
Docker version 18.09.2, community version, Docker desktop version 2.0.0.3(31259), Windows education 1809(17763.316).
Same problem with Docker 18.09.2 on Windows 10 Enterprise (1809, 17763.316).
Still, no one has found a way to solve this problem?
I fixed this by installing Ubuntu and migrating to Linux containers. Might not work for everyone, though.
I have also tried with Docker EE 18.09.3 on Windows Server 2019, same results.
This issue renders almost the whole concept of "Docker for Windows" useless. I wonder why nobody from Docker or Microsoft is commenting.
Can you try using Docker EE 18.09.3? Does it work?
I've just verified that this is still an issue in Docker EE 18.09.5 running on Windows Server 2019 Build 17763.379.
Thank you @gmenounos! Can you please also share which network type is affected? For transparent network persistence you need https://support.microsoft.com/en-us/help/4482887 or above. For the issue where NAT network's aren't being recreated you need Docker EE 18.09.3 (or above)
EDIT: Added (or above)
It was a NAT network. So, you are saying that I should downgrade from 18.09.5 to 18.09.3 for my NAT network to persist across reboots?
As for transparent network persistence and KB4482887, why is that issue not listed in the "Improvements and Fixes" documentation for the KB?
@gmenounos Sometimes KB's don't exhaustively enumerate every single issue that was fixed in the "Fixes" section. This is one such case unfortunately. The KB will not help with the NAT network's not being persisted, only transparent networks specifically.
No, you shouldn't downgrade to Docker EE 18.09.3; you only need Docker EE 18.09.3 or above, so you are good.
NAT networks are not being persisted on Windows Server 2019 by design. Docker creates a default NAT network for you, and recreates it on start of Docker (assuming you have Docker EE 18.09.3 or above). But if you are building your own orchestrator based on the NAT network driver, and creating custom networks you need to recreate the network after restart for containers as well.
@daschott I'm not building an orchestrator. I just had created a custom NAT network, attached a handful of containers to it and noticed that after a reboot I could not restart the stopped containers because their network no longer existed. I cannot just recreate the network and start the containers because the id of the network changes when it's created after a reboot. I guess I will have to try manually attaching the containers to the new network after creating it and then see if I can start them.
The reason I'm using a custom NAT network is so that I can manually assign IP addresses to the containers. The reason I'm manually assigning IP addresses is that I have IIS running on the container host as a reverse proxy and I could not route requests to the containers by container name as the container host cannot resolve the IP addresses of the containers. It was able to do this in Server 2016 but that seems to have changed in Server 2019. I know I could publish port 80 of each container to a unique port on the container host and have the IIS reverse proxy route incoming requests to those ports on localhost but I would prefer not to expose the containers directly on the container host's external network.
Where is it documented that NAT networks are not persisted by design on Windows Server 2019? This came as a surprise to me right now, especially given the fact that on Ubuntu the custom NAT networks are persisted. All deviations in behavior across platforms should be noted somewhere in capital letters along with good justifications (if there already isn't such document).
https://docs.microsoft.com/en-us/virtualization/windowscontainers/container-networking/network-drivers-topologies
document write: "NAT networks created on Windows Server 2019 (or above) are no longer persisted after reboot."
But he did not explain why.
Doesn't this make using custom Docker networks completely pointless? I don't get how this could possibly have made it into a released version of Windows.
I am seeing the same behavior on Docker Desktop (Win10 1803 & 1809, haven't checked higher yet)
Also, what on earth rationalizes blowing away a custom network that a user has specified to run their containers with? Really would like to understand the justification for this because simply saying "by design" when the design appears as an inherent disadvantage only fosters confusion and erodes trust in the solution.
Container networks of type “NAT” are not persisted on Windows Server 2019 after reboot. That being said, the Docker service is responsible for creating its own default NAT network. This means that after reboot, the default NAT network will be present again after the Docker service has launched again. Containers that were attached to the old NAT network and persist after reboot (e.g. using --restart always flag) should re-attach to the fresh default NAT network and behave/connect exactly the same way as before reboot after Docker service start. If it doesn’t then there is a bug.
Please make sure you're using the latest Docker version as any version below Docker engine 18.09.3 on Windows Server 2019 may have problems since it will use the old logic of container attachment.
The reason why this was done is so that users can expect a fresh and clean environment without any leaking network resources after reboot, which NAT is prone to.
If you want to specify a custom subnet for the default NAT network (e.g. 10.0.0.0/24), you should also be able to set {"fixed-cidr" : "10.0.0.0/24"} in the Docker daemon.json file located under C:\ProgramData\docker\config\daemon.json
If you need another network that needs to be persisted there is also l2bridge network driver which is more performant and widely used in SDN, Kubernetes, etc. and has additional security features like micro-segmentation using network ACLs.
@liberdis @sandersaares @gmenounos Can you share your use-case for needing multiple custom NAT networks? It would be really helpful as I can pass on the feedback to people that made the persistence decision.