Oci-container systemd service not able to stop

I’m running the “earxng/searxng:latest” docker container with:

  virtualisation = { # {{{
    oci-containers.backend = "docker";
    oci-containers.containers = {
      SearxNG = {
        image = "searxng/searxng:latest";
        # extraOptions = [ "--restart=unless-stopped" ];
        # autoStart = true;
        ports = [ "8888:8080" ];
        environment = {
          BASE_URL = "http://localhost:8888";
          INSTANCE_NAME = "aLaptop SearxNG";
        volumes = [
  }; # }}}

My problem is that the systemd service won’t stop and has to get timed out after 120 seconds. The generated systemd service is:

# /etc/systemd/system/docker-SearxNG.service
After=docker.service docker.socket network-online.target



If I run the ExecStop script it only runs for 10 seconds to stop the container, and ExecStopPost script runs in milliseconds to remove the container. However when systemd runs those two commands it takes 2 minutes.

I have tried:

  • Switching from podman back end to the docker back end
  • Adding the flag “–restart=unless-stopped”
    • This had the unintended side effect of not auto starting the container so I added “autoStart = true” to the configuration.nix.
  • Checking the service logs with journalctl -u docker-SearxNG.service when running SearxNG and nothing unusual was in there.
  • Checking the service logs with journalctl -u docker-SearxNG.service after stopping the service and the logs didn’t change from when it was running.

I don’t know what else to test or where to look to fix the issue, thanks for the help!

I’m not able to test anything at the moment, but have you tried adding the --init flag to the docker run command? I’ve used that before with some containers that took a long time to stop.

Too bad it doesn’t work for my podman jellyfin container!

Adding the --init flag did not change anything. Apparently tini wasn’t able to accept zombie processes so I added the environment variable TINI_SUBREAPER and nothing changed with either of those changes.