Ubuntu: Networking - Docker and KVM on the same box

If you like me have a box which is running everything, like; Docker, kvm and lxc then you probably also once in a while get gray hair from sorting out networking. 

So Docker like to control networking and I let it - only exception is that I'm having a separate bridge (macvlan) for everything Docker as it does sometimes makes life easier (not often).

But as Docker see everything, even with multiple network cards / bridges as one whole, it does apply it's iptables rules to everything. Which does cause some problems for kvm and lxc. 

One easy way to allow communcation to the kvm vm's via your bridge (if you use bridged networking) is to allow it:

iptables -A FORWARD -i br0 -o br0 -j ACCEPT

Replace 'br0' with what ever you use as bridge for kvm / lxc.

To have this to execute automatically everytime you retart networking (reboot the box) create the following file: /etc/systemd/system/restore-iptables-rules.service

With this content:

 Description = Apply iptables rules  
 ExecStart=/bin/sh -c 'iptables -A FORWARD -i br0 -o br0 -j ACCEPT'  

Make it stick: systemctl enable restore-iptables-rules.service

And Bob's your Uncle.


Popular posts from this blog

Kviknet and IPv6

Apple AirPort Express and Digital Jitter..

Apple IOS cannot download song