docker-net-dhcp
docker-net-dhcp copied to clipboard
Host system not not reachable anymore after a while
I have performed the setup as suggested in "Network creation" as well as creating the network. After container creation, things seem to work perfectly, but after a while, I lose connectivity to the host system, I cannot reach the docker host. The containers running seem to be ok and running. The host system network is not reachable anymore.
The docker host is a raspberry pi 4/4GB Docker version is 20.10.11, build dea9396
Cannot find documentation to point to now but a Linux bridge automatically uses the lowest mac address attached to it at any given time. Hence, if you don't explicitly set the mac address on the bridge interface it will change over time and you will experience exactly the behaviour you are describing (IE: you want to set the mac address on bridge creation to the same address as the underlying physical ethernet interface).
@gustafg You suggest e.g.:
# Create the bridge
$ sudo ip link add my-bridge type bridge
$ sudo ip link set my-bridge macaddr <MAC-of-eth0>
$ sudo ip link set my-bridge up
.......
Yes, exactly.
@gustafg
Yes, exactly.
When I do this I get:
sudo ip link set my-bridge macaddr <MAC-of-eth0-got-from-ip-link-ls>
Error: either "dev" is duplicate, or "macaddr" is a garbage.
Googled around, so far no luck
The exact syntax seems to be:
ip l set my-bridge address aa:bb:cc:dd:ee:ff
Still having this issue, the host is unable to connect to the internet, while the containers have proper connection.
may be this discussion will help someone: superuser-link
I read over eveything, Could you explain the steps you took to do this?
In the terms what I experienced, as soon as do the steps, specifically,
ip link add dhcp-bridge type bridge
ip link set dhcp-bridge up
ip link set usb0 master dhcp-bridge
dhcpcd dhcp-bridge
#Create Docker Network Driver
docker network create -d ghcr.io/devplayer0/docker-net-dhcp:release-linux-amd64 --ipam-driver null -o bridge=dhcp-bridge docker-dhcp
The thing is, sometimes it works(for some time) on my tethered connection, but never on the ethernet connection that i have in my university, I don't know what goes wrong here.
(Here works mean both container and host networking works, and in case of ethernet, only container networking works)
Next thing, as per the link i given link, the discussion says that running the dhcpcd dhcp-bridge
should get ip for dhcp-bridge
interface which is connected to host-port
of the virtual switch,
and it should give smooth host networking, but that doesn't seem to work.
In fact, container networking seems to work fine in both the cases, so in case you don't require host to be able to reach, but only containers, this gets that done.
After all this hassle, I shifted to docker macvlan driver, I know that it doesn't solve the issue of dhcp, but, atleast it lets the containers to be on the same network as the host, where i can do something for DHCP related stuff to let containers get ip from DHCP of host network. And i am sure this works fine.
Again if you are not specifically tied to docker, LXD is better choice for this specific use-case, As I have tested it rigorously and it exactly solves the same thing this project tries to solve.
How would I do LXD with raspberry pi? I'm tryna run a few containers on few pi's and was going to expose them to the host network to avoid port conflicts when running multiple instances.
That's an interesting thing!
Well in that case the clustering of nodes in LXD is much better and easy as per my knowledge and works well with rapberry pi's
this LXD project lead has nice walkthrough especially in lxd clustering, and in fact, he has setup the cluster of few raspberry pi's for the demonstration:
link-to-video
thank you, Will try this.
Yup, you simply need to attach containers or those vms to the network, if your ethernet interface name is eth0
, it will list under
lxc network list
and you can simply attach eth0 to the container, allowing the container to exist on the network as of host, and will get ip from DHCP directly.
lxc network attach eth0 my-container
and getting bash terminal similar to docker command
lxc exec my-container /bin/bash