well, neither pipework or network_wrapper work anymore
but I have it working, under a vm without promiscuous mode…
updated… no timing problem
1. create a docker network with the same address range as the network u want your containers in
if from the host then you can get the info from ip route
ip_address_for_network script
ROUTE_INFO=$(ip route | grep default )
IPGW=$(echo $ROUTE_INFO | awk '{ print $3}')
IP_INTERFACE=$(echo $ROUTE_INFO | awk '{ print $5}')
OUR_ADDRESS=$(ip addr | grep -A1 $IP_INTERFACE | grep "inet " | awk '{print $2}' | awk -F "/" '{print $1}')
NETINFO=$(ip route | grep -m1 $OUR_ADDRESS | awk '{print $1}')
echo --gateway=$IPGW --subnet=$NETINFO
docker network create -d macvlan $(./ip_address_for_network) network_name
2. generate a mac address (docker will reuse the same ones all the time)
( use something unique)
mac_from_string script
#!/bin/bash
echo $1|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/'
3. run a busybox udhcpc task to get a dhcp server assigned address for that mac address
docker run --net network_name --cap-add NET_ADMIN --rm --mac-address **_mac_from_step_2_** busybox udhcpc -x "hostname:whatever u want" | grep lease | awk '{print $4}'
this container will request an ip address from the dhcp server on the 'network' using the mac_address.
and then die --- need to do: renew lease til the actual container ends.. need to figure out docker events.
4. start your container, using the mac address u generated in step 2 and the ip address from step 3
docker run -d --net network_name --mac-address "from step 2" --ip "from step 3" other_options image image_parms
steps 2-4 need to be done for every container being started