Parallels / docker-machine-parallels

Parallels driver for Docker Machine https://github.com/docker/machine
MIT License
471 stars 35 forks source link

Support "bridged" network mode #41

Closed sheerun closed 4 years ago

sheerun commented 8 years ago

Hey

This driver for now uses /Library/Preferences/Parallels/parallels_dhcp_leases that shows ip assigned by parallels' dhcp. I changed network mode of contained to "bridge" so my containers are exposed in local network, but docker-machine ip still shows old ip address from parallels_dhcp_leases.

Could you implement support for bridged mode, please?

legal90 commented 8 years ago

Hi @sheerun Thank you for request! Like in Vagrant provider, here in Machine driver we use "Shared" network type by default, because it works for everybody and it doesn't depend on any external conditions. However, "Bridged" mode depends on the configuration of a network, which the host machine is currently connected to. There could be a static IP in some specific subnet or an auto-configuration by DHCP, or the host could be just off-line, so the network could be even not configured.

Adding "bridged" mode as an additional option sounds good, and we're open for Pull-Requests allowing this. But honestly, I'm not sure how it could lay on the Docker Machine workflow. Also I'm looking forward to the way how the similar feature will be implemented in the upstream Docker Machine for the VirtualBox driver: https://github.com/docker/machine/issues/1491

At the moment, I recommend you to add a second network adapter with a type "Bridge", because reconfiguring of the existing one will brake the Docker Machine driver - it won't be able to connect to the VM.

dersimn commented 7 years ago

+1

Elhodred commented 7 years ago

Adding a second adapter works only if you access your containers from the same network configured in the bridge interface. This is due the fact that you will end up with 2 default routes in the routing table: docker@default:~$ ip route list default via 10.211.55.1 dev eth0 metric 1 default via 192.168.1.1 dev eth1 metric 1

I don't find a way to remove persistently the "wrong" default route to make my setup working. Is there a way to reconfigure the VM to have only one interface in a way that the connection from docker-machine is not broken?

HunterDG commented 5 years ago

+1

Glad I found this issue!

Workaround: docker-machine create --driver parallels default docker machine env to find the "Shared" IP docker-machine stop change the network interface to bridged in parallels config, then manually start the VM run ip a or ifconfig in the docker VM to find new bridged IP replace "Shared" with bridged IP in /Library/Preferences/Parallels/parallels_dhcp_leases, save file docker-machine regenerate-certs default docker-machine env

Voila! :) now I can run homebridge in docker on mac! (until DHCP lease changes on bridged network, or parallels decides to overwrite the dhcp leases file)

EDIT: lock the DHCP leases file if you don't have/intend to create any new VMs with shared network interfaces.

Alternative more permanent workaround I haven't tried (and assuming no other VMs use shared networking) could be to set a DHCP reservation in the bridged network DHCP server, then modify Parallels "Shared" network DHCP prefs to hand out only that IP address. Then you'd theoretically only need to change the network interface to bridged, and presumably Parallels wouldn't overwrite the DHCP leases file.

legal90 commented 4 years ago

Hi all, Since Docker Machine was put into the maintenance mode (https://github.com/docker/machine/issues/4537) there is almost no chance that the Bridge network support will be officially added there (https://github.com/docker/machine/issues/1491). Therefore, we are not going to implement it in parallels driver neither.

For those of you, who still need that, I would recommend using the workaround posted by @HunterDG in the comment above.

HunterDG commented 3 years ago

FYI - not explicitly related to this issue, but relevant to my need at the time (homebridge/other containers that require bridged (net=host) don't work in Docker Desktop)...

There is now a homebridge-vm-image that negates the need for docker-machine.