问题
Since Docker for Mac does not use Virtualbox but rather uses xhyve there is no straightforward way to access my mac's network (specifically for VPN and network attached devices) using network_mode: host
or --network host
.
I've searched and searched but have found no simple workaround. The best solution I've figured out is to run a Linux virtualbox then install docker on that and execute docker-compose up
or docker run
in there. Not ideal at all.
回答1:
This doesn't seem to be possible. There are some limitation in docker for mac. https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds
On the other hand, starting a VM and installing docker on it might not help. With network mode as host, the container will use directly the network interfaces for the VM and not those of the MAC host. So you will end up in a case similar to that of using docker directly on your mac machine.
来源:https://stackoverflow.com/questions/46286741/is-there-a-workaround-to-use-the-hosts-network-in-docker-for-mac