Extra-container - Run declarative containers without full system rebuilds



sudo extra-container create --start <<'EOF'
  containers.demo = {
    privateNetwork = true;
    hostAddress = "";
    localAddress = "";

    config = { pkgs, ... }: {
      networking.firewall.allowedTCPPorts = [ 50 ];

      systemd.services.hello = {
        wantedBy = [ "multi-user.target" ];
        script = "while true; do echo hello | ${pkgs.netcat}/bin/nc -lN 50; done";

curl # Returns 'hello' from the container


This is awesome!
Other than that, I’m playing around with it already and writing some containers that I’ll use instead of docker-compose or nixos-shell. Given that it’s using a super solid foundation I don’t think there’ll be any issues, but that’s just what we needed.
Thank you very much!

(removed ignorant comment about list missing)


Also update action is missing. Do I have to destroy/add/start each time configuration changes?


@danbst, no, just run extra-container create --restart with an updated config. Or use --start to start the container even if it’s not already running.
But note that this doesn’t clear the contents of the container directory in /var/lib/containers/. Would this be required for your use case?


How does this differ from NixOps with a container backend?


@manveru, your comment wasn’t ignorant at all, I forgot to document the list command. It’s fixed in the latest update.


@tom, the NixOps container backend uses imperative containers which lack some options of declarative containers.


Perhaps add this as another nixops target/option? I’m seeing a period of rapid progress of experimentation and think the community should try to consolidate and mature some tools before it becomes too fragmented.


I think this should be integrated into nixos-container so that there’s feature parity between imperative and declarative containers. There are a few kinks left to work out, then I’ll open an issue.


I had success with running declarative containers with this piece of software on non-NixOS (Ubuntu). I’ve documented problems in https://github.com/erikarvstedt/extra-container/issues/1

That’s really awesome!