Skip to content

Commit 4072ce8

Browse files
committed
Manually apply MAC address when supplied (fixes #1)
If specified (via `--mac-address`), Docker only applies a user-selected MAC address when moving the interface into the container's network namespace. This means that the initial run of `udhcpc` will use the random veth MAC address, breaking any statically configured leases (since this is the IP address that Docker will assign to the container).
1 parent 7933149 commit 4072ce8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net-dhcp/network.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ def create_endpoint():
161161
}
162162

163163
try:
164-
if 'MacAddress' not in req_iface or not req_iface['MacAddress']:
164+
if 'MacAddress' in req_iface and req_iface['MacAddress']:
165+
(if_container
166+
.set('address', req_iface['MacAddress'])
167+
.commit())
168+
else:
165169
res_iface['MacAddress'] = if_container['address']
166170

167171
def try_addr(type_):

0 commit comments

Comments
 (0)