问题
My host is SLES12 VM running on an ESX server. VM Host has interfaces which acquire DHCP IPs from the DHCP server running on ESX.
In my docker container (docker image: opensuse) I am running a NFS server and hence need external access. I want the container to acquire dhcp IP from the dhcp server running on ESX (just like my Host VM gets).
I have tried pipework but could not get it working. Here is what I did:
Enabled Promiscuous mode on ESX. Created new bridge (br1) and
attached it to Host interface eth0.Using pipework added a new interface (eth1) in Docker container with an IP address using this command
pipework br1 $CONTAINERID 0/0
After I tried assigning DHCP IP to the new interface (eth1) of the container, using the command
pipework eth1 $CONTAINERID dhclient
But got the below error:
RTNETLINK answers: File exists
To resolve this I flushed the eth1 device in the container and ran the command again. I observe that my docker daemon crashed. Docker version: 1.12.3 (both client and server).
Please let me know what I am missing here. I want my container's interface/s to acquire the DHCP IPs from DHCP server running on ESX.
回答1:
You will need to create a docker network with the macvlan or ipvlan driver. Then you will need to use the DHCP IPAM driver (IPAM stands for IP Address Management).
Here is a gist with some explanations of how to do something similar: https://gist.github.com/nerdalert/3d2b891d41e0fa8d688c
来源:https://stackoverflow.com/questions/43394826/how-to-configure-a-docker-container-for-acquiring-dhcp-ip-s-from-dhcp-server-run