0

I have a wireless usb adapter and I would like my docker container to use just this for the internet (not the computers own wireless adapter).

My knowledge of networking is basic so I have tried to read a lot to work out how to do this but I'm completely out of my depth.

So far I have unsuccessfully tried the following (enx582c80139263 is the usb wireless adapter):

1) create a network namespace for the container and to move the wireless adapter to that (by following this):

sudo docker run -dit --rm --privileged --net none --name mycontainer debian
pid=$(sudo docker inspect --format '{{.State.Pid}}' mycontainer);
sudo mkdir -p /var/run/netns;
sudo ln -s /proc/$pid/ns/net /var/run/netns/$pid;
sudo ip link set dev enx582c80139263 netns $pid;

When I do this, the adapter no longer show an ip address when I do ifconfig. I'm not sure of the process of how the wireless adapter gets an ip address normally when in the global namespace, so I got stuck here

2) create a network namespace for the container and then creating veth pair, with one veth in the container namespace and the other in global namespace. Then I gave them ip addresses and used a bridge (brctl) to connect the wireless adapter interface to the global namespace veth.

sudo docker run -dit --rm --privileged --net none --name mycontainer debian
pid=$(sudo docker inspect --format '{{.State.Pid}}' mycontainer);
sudo mkdir -p /var/run/netns;
sudo ln -s /proc/$pid/ns/net /var/run/netns/$pid;
sudo ip link add veth0 type veth peer name veth1
sudo ip link set veth1 netns $pid
sudo ip netns exec $pid ifconfig veth1 10.0.0.1/24 up
sudo ifconfig veth0 10.0.0.2/24 up
sudo brctl addbr br0
sudo brctl addif br0 enx582c80139263 veth0

I can ping from one veth to the other before adding the global veth to the bridge, but can't after I add it. Not sure why

Also, one I connect the wireless adapter to the bridge I can't access the internet (I thought that the internet would be accessible from the in build wireless card because I am still connected to the wifi).


I may be going about this completely the wrong way...literally learnt about networking and docker in the past few days. Please let me know if I should be approaching this a different way

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.