![]() cap-add=NET_ADMIN have rights for administering the net (i.e. This worked for me: docker run -cap-add=NET_ADMIN -d -it myimages/image1 /bin/sh -c "/sbin/ip addr add 172.17.0.8 dev eth0 bash" Using this approach I run my containers always with net=none and set IP addresses with an external script. $ sudo ip netns exec $pid ip route add default via 172.17.42.1 $ sudo ip netns exec $pid ip addr add 172.17.42.99/16 dev eth0 $ sudo ip netns exec $pid ip link set eth0 up $ sudo ip netns exec $pid ip link set dev B name eth0 # rename to eth0, and activate it with a free IP ![]() # Place B inside the container's network namespace, $ sudo ip link add A type veth peer name B # bind the A end to the bridge, and bring it up # Create a pair of "peer" interfaces A and B, # Check the bridge's IP address and netmask $ sudo ln -s /proc/$pid/ns/net /var/run/netns/$pid # for the "ip netns" command we will be using below ![]() # and create its namespace entry in /var/run/netns/ # At another shell, learn the container process ID $ sudo docker run -i -t -rm -net=none base /bin/bash I’m using the method written here from the official Docker documentation and I have confirmed it works: # At one shell, start a container and
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |