I made a package for zyre and wanted to play around with it inside nixos containers.
zyre.nix
with import <nixpkgs> { };
stdenv.mkDerivation rec {
pname = "zyre";
version = "2.0.0";
src = fetchFromGitHub {
owner = "zeromq";
repo = "zyre";
rev = "latest_release";
sha256 = "1iwg0yqnrn8njjqv2ycifygzxrwd5g5kaszln0hy05m1c0xi44ik";
};
nativeBuildInputs = [ cmake asciidoc libsodium zeromq czmq ];
enableParallelBuilding = true;
doCheck = false; # fails all the tests (ctest)
meta = with stdenv.lib; {
branch = "latest_release";
homepage = https://github.com/zeromq/zyre;
description = "A Framework for Distributed Computing";
license = licenses.mpl20;
platforms = platforms.all;
};
}
Zyre comes with a utility called “zping” which can be used for testing it’s functionality.
Opening two terminals on my machine and executing it looks something like this:
term1$ zpinger
I: 20-02-14 16:27:49 Create Zyre node, uuid=9714E9D4DCC2A9400BED4C99C230CE9C, name=9714E9
I: 20-02-14 16:27:51 [E3E3FD] peer entered
I: 20-02-14 16:27:51 [E3E3FD] received ping (WHISPER)
I: 20-02-14 16:27:51 [E3E3FD](GLOBAL) received ping (SHOUT)
term2$ zpinger
I: 20-02-14 16:27:51 Create Zyre node, uuid=E3E3FDBF0CB48F3238192F48548FF0E6, name=E3E3FD
I: 20-02-14 16:27:51 [9714E9] peer entered
I: 20-02-14 16:27:51 [9714E9] received ping (WHISPER)
I: 20-02-14 16:27:51 [9714E9](GLOBAL) received ping (SHOUT)
Doing the same inside a nix container shows that it does not work there…
Here is a stripped down (untested) version of my container:
container.nix
{
containers.host1 =
{
privateNetwork = true;
hostAddress = "192.168.100.1";
localAddress = "192.168.100.10";
config = {
networking.firewall.enable = false;
environment.systemPackages = with pkgs; [
(import zyre.nix)
];
};
};
}
AFAIK zyre relies on UDP multicast which appears to be enabled inside the container.
[root@host1:~]# ip a
2: eth0@if78: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 56:a8:da:04:53:86 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.100.10/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::54a8:daff:fe04:5386/64 scope link
valid_lft forever preferred_lft forever
UDP itself appears to be working inside (and between) containers which I tested with netcat like so:
[root@host1:~]# nc -l -u 1234
[root@host1:~]# nc -v -u 192.168.100.10 1234
Connection to 192.168.100.10 1234 port [udp/search-agent] succeeded!
Obviously the problem must be related to container networking but I am relatively new to NixOS and
out of ideas.
Is there anybody who can give some insight on how container networking works in regard to this issue and/or reproduce this behaviour?