How to start oci-container without autostart

Hi all,

I’m trying to add a container to my config with:

  virtualisation.docker = {
    enable = true;
    enableOnBoot = true;
    };
    virtualisation.oci-containers = {
      backend = "docker";
      containers = {
        nocodb = {
          image = "nocodb/nocodb:latest";
          ports = ["8080:8080"];
          volumes = ["/home/xxx/nocodb:/usr/app/data/"];
        };
      };
  };

If I do sudo nixos-rebuild switch --flake .#, I get a service docker-nocodb and I can log in and use it fine. However, without the autoStart option, I don’t get this service anymore on reboot. I mean I can’t start it with systemctl start docker-nocodb or something similar and I can’t see it either under systemctl list-units --all | grep nocodb or in the actual .service files under /run.

How can I do this: “If this option is set to false, the container has to be started on-demand via its service.”?

$ sudo nixos-container start nocodb

or

$ sudo systemctl start container@nocodb

1 Like

Yes that’s the command! Thanks. I’m a bit ashamed to say that the problem was something else, trivial: my boot partition was full. nixos-rebuild loaded the new config but after reboot it was still the old version. And there was a warning / error message. :roll_eyes:

And here’s convenient little helper:

{
  environment.systemPackages = with pkgs; [
        (resholve.writeScriptBin "container-status"
          {
            interpreter = runtimeShell;
            inputs = [ coreutils nixos-container ];
            execer = [ "cannot:${getExe nixos-container}" ];
          }
          ''
            printf '%-12s %-6s\n' Name Status
            for c in $(nixos-container list); do
              status=$(nixos-container status $c)
              printf '%-12s %-6s\n' $c $status
            done
          '')
      ];

  ]
}
1 Like