jpetazzo / pipework

Software-Defined Networking tools for LXC (LinuX Containers)
Apache License 2.0
4.21k stars 727 forks source link

bonjour / multicast / mdns across macvlan ? #157

Closed dreamcat4 closed 8 years ago

dreamcat4 commented 9 years ago

Hi, I've been using pipework for a while now and am pretty happy with it. However one thing I noticed was that the containers are not advertising multicast services on my LAN.

Using the standard macvlan mode (where pipework creates for me the macvlan circuit of each container). Perhaps this is something can be looked into?

More specifically, I think long ago I tried to manually add the MULTICAST flag to my container's pipework inside interface. But it didn't work.

I think my main question is whether it is only the MULTICAST flag purely the problem, or if there are other technical hurdles / issues. Actually I looked just now inside my containers and they all seems to have the MULTICAST flag switched on. Same as the host interface. So what's might be the problem?

Another question is if something along these lines can be more easily acomplished by switching to OVS, which I confess I don't understand much of at this point. OVS seems to have it's own terminology and is not immediately obvious what to do to produce the desired outcome.

dreamcat4 commented 9 years ago

My pipework commands look like this:

https://github.com/dreamcat4/docker-images/blob/master/tvh/example-crane.yml#L20

jpetazzo commented 9 years ago

I've built this image:

FROM ubuntu:14.04
RUN apt-get install -qy avahi-daemon
CMD mkdir /var/run/dbus && dbus-daemon --system && avahi-daemon

Then started it, then:

pipework eth0 $(docker ps -lq dhcp)

... And then I was able to ping (and therefore resolve) <container_id>.local.

Is there anything I could try on my end?

dreamcat4 commented 9 years ago

Hi again @jpetazzo Thanks for showing an interest in multicast feature. Usually this feature is not essential, but still a very pleasant / nice to use.

Actually over the past 2 weeks i've actually seen multicast discovery items appear perhaps 2 times. Which suggests in principle it might be possible.

The way i've been trying to use multicast is with some real nDNS / mDiscovery service or server. Namely either tvheadend or samba / netBios advertisement of samba shares.

A more thorough way of testing would be with wireshark / ethereal / whatever. And binding a listen to some 239.*.*.* multicast address & some specific chosen uPNP port. Although I really have not had time for such things.

The only thing I know to check for (it's quite basic). Is make sure that the MULTICAST flag is enabled on both of the host networking adapter, and also that it appears with output of ifconfig inside the container too (where is providing some multicast server or other service).

For the multicast client I always use some host machine or other real network computer which is on the local LAN.

dreamcat4 commented 9 years ago

I confess I have not actually used or setup the avahi daemon myself before. Perhaps I must try what you are doing. See if it makes a difference. Still need to find the time. Maybe after 1 week more other stuff, I can return to this.

jpetazzo commented 9 years ago

Normally multicast will just work fine. If there's a particular scenario that doesn't work, let me know how to reproduce!

dreamcat4 commented 8 years ago

Good news! Multicast working is working for me now. Sorry for raising this issue - the feature working absoloutely fine in pipework.

The key components necessary:

The worst one to get working is ^ dbus. But once those other dependancies are all working properly, then 'it just works'.

My own working example is not up / available yet (dreamcat4/forked-daapd). But you can see elsewhere this solution in other people's forked-daapd images. A program for serving music libraries to iTunes clients.

In short:

ubuntu-debootstrap + s6-overlay

# start dbus
mkdir -p /var/run/dbus
chown -R messagebus:messagebus /var/run/dbus
dbus-uuidgen --ensure
dbus-daemon --nofork --system --nopidfile &

# start avahi
avahi-daemon --no-chroot &

# then start your server / daemon

Again sorry for any false reports here. Closing.

jpetazzo commented 8 years ago

Thanks for reporting back — I remember that setting up avahi in containers was tricky; so your comments here might help others!