Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host system not not reachable anymore after a while #27

Open
lukicsl opened this issue Dec 10, 2021 · 13 comments
Open

Host system not not reachable anymore after a while #27

lukicsl opened this issue Dec 10, 2021 · 13 comments

Comments

@lukicsl
Copy link

lukicsl commented Dec 10, 2021

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

@lukicsl lukicsl changed the title am performing the setup as Host system not not reachable anymore after a while Dec 10, 2021
@gustafg
Copy link

gustafg commented Apr 21, 2022

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).

@lukicsl
Copy link
Author

lukicsl commented Apr 21, 2022

@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
.......

@gustafg
Copy link

gustafg commented Apr 22, 2022

Yes, exactly.

@lukicsl
Copy link
Author

lukicsl commented Apr 22, 2022

@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

@gustafg
Copy link

gustafg commented Apr 22, 2022

The exact syntax seems to be:
ip l set my-bridge address aa:bb:cc:dd:ee:ff

@VaradBelwalkar
Copy link

Still having this issue, the host is unable to connect to the internet, while the containers have proper connection.

@VaradBelwalkar
Copy link

VaradBelwalkar commented Nov 5, 2023

may be this discussion will help someone: superuser-link

@tbhbestdevman
Copy link

I read over eveything, Could you explain the steps you took to do this?

@VaradBelwalkar
Copy link

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.

@tbhbestdevman
Copy link

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.

@VaradBelwalkar
Copy link

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

@tbhbestdevman
Copy link

thank you, Will try this.

@VaradBelwalkar
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants