Is it possible to start a oci container after a systemd unit

I have a oci container which is running PiHole. I use it in combination with Unbound (as a NixOS service not a contaire image).
However I have the problem that the PiHole container gets started to soon and then can’t get the upstream DNS entries.
Is there a way to delay the start or make it so that it only runs after Unbound is up?

1 Like

Yes, you can modify its systemd service. Something like:

{config, ...}: let
  service-name = "${config.virtualization.oci-containers.backend}-<conteiner-name>";
In {${service-name}.after = [""];

Or I suppose “unbound.service”.

There are some caveats to this, like what happens if the network never starts, but generally it should work well: Running Services After the Network Is Up


Thank you, that worked :+1: