问题
There is an option in docker-desktop that allow to change the "Docker subnet". And I don't see this default subnet 192.168.65.0/28
being used anywhere.
I tried to docker network inspect
on every Docker internal network, checked the docker-desktop WSL2 distro and my Windows host for routes or IPs but I don't see that default subnet being used anywhere (even when setting up a custom one).
This does not change the subnet used in docker network inspect bridge
or any other one.
I'm struggling to find any documentation on what it is and/or what it used for.
回答1:
For the most part it is an internal implementation detail that you don't need to worry about.
The only time you actually need to change this value is if your host network has the same address. In that case you can change this to anything that doesn't conflict. If your host network happens to be, for example, 192.168.65.0/24 then you could change the Docker network to 192.168.66.0/24 (or /28) and it'd work fine.
Internally containers have individual IP addresses, and this is the default subnet they get assigned from. If you docker network create
a network or you're using Docker Compose, a new subnet will be allocated. This is almost entirely an implementation detail and you never need to know these addresses: from outside Docker you can't reach these addresses (*), and inside Docker it provides a DNS system so you can use container names as host names.
More specifically, if you
docker run --rm busybox ifconfig
you will see an address from this subnet.
(*) ...except in the one very specific case of connecting from the console of the native-Linux host that's actually running the containers; but never from other hosts, or if you're using Docker Toolbox or Docker Desktop.
来源:https://stackoverflow.com/questions/62849480/what-is-the-docker-subnet-used-for