r/LinuxContainers • • Nov 02 '18

Installing Docker breaks my LXCs bridge to the LAN/DHCP - how to get them living side by side?

I have a home microserver set up so all it's networking goes through a bridge, which allows my lxc containers to fetch an IP through DHCP on my router (router applies static IP via mac address). Essentially what this blog post describes.

But every time I install Docker it creates its own bridge and breaks LXC container networking. So I uninstall and fix things...

I'd really like to play with docker, if nothing else it would make some app installs easier. So I'm looking for advice on getting both running side by side.

Have you done it? Can containers still fetch an IP via DHCP? How?

TIA

2 Upvotes

6 comments sorted by

1

u/[deleted] Nov 08 '18

Hadn't realized how man iptables rules docker inserts. Turns out they somehow block either incoming or outgoing traffic to the LXC containers.

I've told the docker daemon not to mess with iptables by creating /etc/docker/daemon.json with the contents:

{
  "iptables" = "false"
}

After a reboot my lxc containers can one again grab an IP from the router.

Downside will be the need to manually manage iptables for any docker containers I install.

1

u/[deleted] Nov 02 '18

Why do you use that blog post's recommendations rather than using the lxcbr0 option?

Can you install Docker within a container? That is less likely to mess with your host networking.

This information may help diagnose the issue:

$ ip address
$ ip link
$ ip route
# sysctl -a -r '^net.*'

Compare between before and after Docker creates its bridge.

1

u/[deleted] Nov 02 '18

I'not sure why I don't use lxcbr0 - its been years since I first set this up! It's quite possible LXCs network capabilities were less sophisticated at the time. Would lxcbr0 allow the containers to sit on the same LAN? I suspect it was about using the same subnet and allowing the router to assign a fixed IP (and a domain name).

Thanks for the tips, I'll investigate further.

1

u/[deleted] Nov 03 '18

With the lxc-net configuration, your host machine acts as the router (running a DHCP and DNS server implementation called dnsmasq). You can set static IPs in the LXC configuration or in the dnsmasq configuration.

1

u/[deleted] Nov 04 '18

Did a bit of reading, lxc-net doesn't allow containers on the same subnet, or to pick up an IP from my router. I need to access the containers from other machines on the network so the shared bridge with the host is simpler. (I have dnsmasq on my openwrt router).

Installing Docker in an LXC container? I know its possible, just seems overly complex.

1

u/[deleted] Nov 04 '18

Short answer from this: The official docker-ce package install creates two new bridges, docker0 and lxdbr0. Presumably the latter is what kills lxc container networking.

For the sake of brevity, here's 'ip link' after:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP mode DEFAULT group default qlen 10000
link/ether 44:1e:a1:3e:e0:4f brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether 44:1e:a1:3e:e0:4f brd ff:ff:ff:ff:ff:ff
4: lxdbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether 5e:6c:b0:ea:9d:c4 brd ff:ff:ff:ff:ff:ff
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default 
link/ether 02:42:99:63:6f:5d brd ff:ff:ff:ff:ff:ff
7: vethC06EU4@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
link/ether fe:e4:db:7a:bc:b9 brd ff:ff:ff:ff:ff:ff link-netnsid 0

1,2,3 are identical to before. 4 & 5 are new. 7 is an LXC container which is now unable to reach my router.

Here's 'ip route' after:

default via 192.168.0.1 dev br0 onlink initrwnd 10 
10.77.73.0/24 dev lxdbr0 proto kernel scope link src 10.77.73.1 
169.254.0.0/16 dev br0 scope link metric 1000 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.0.0/24 dev br0 proto kernel scope link src 192.168.0.10 

Will investigate further.