nixos/oci-containers: wait for network before starting container

Without `ìmageFile` set, the service needs to download the image from
the registry. If the network is not up in time, the service tries to
restart rapidly until it fails.
This commit is contained in:
sohalt 2022-08-29 11:56:16 +02:00
parent 25f7edccc7
commit 995853d13c

@ -229,7 +229,10 @@ let
dependsOn = map (x: "${cfg.backend}-${x}.service") container.dependsOn;
in {
wantedBy = [] ++ optional (container.autoStart) "multi-user.target";
after = lib.optionals (cfg.backend == "docker") [ "docker.service" "docker.socket" ] ++ dependsOn;
after = lib.optionals (cfg.backend == "docker") [ "docker.service" "docker.socket" ]
# if imageFile is not set, the service needs the network to download the image from the registry
++ lib.optionals (container.imageFile == null) [ "network-online.target" ]
++ dependsOn;
requires = dependsOn;
environment = proxy_env;