summary refs log tree commit diff
diff options
context:
space:
mode:
authorsohalt <sohalt@sohalt.net>2022-08-29 11:56:16 +0200
committersohalt <sohalt@sohalt.net>2022-09-07 17:28:00 +0200
commit995853d13c53c182781b14e00b91ea20ce98257f (patch)
tree7b53c42d0b9f3be2196b90582a862f7a8a8a0375
parent25f7edccc7051779cbfdd6d9a684f899493c638d (diff)
downloadnixpkgs-995853d13c53c182781b14e00b91ea20ce98257f.tar
nixpkgs-995853d13c53c182781b14e00b91ea20ce98257f.tar.gz
nixpkgs-995853d13c53c182781b14e00b91ea20ce98257f.tar.bz2
nixpkgs-995853d13c53c182781b14e00b91ea20ce98257f.tar.lz
nixpkgs-995853d13c53c182781b14e00b91ea20ce98257f.tar.xz
nixpkgs-995853d13c53c182781b14e00b91ea20ce98257f.tar.zst
nixpkgs-995853d13c53c182781b14e00b91ea20ce98257f.zip
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.
-rw-r--r--nixos/modules/virtualisation/oci-containers.nix5
1 files changed, 4 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/oci-containers.nix b/nixos/modules/virtualisation/oci-containers.nix
index 81cdf1dd72b..ed04e6a56a2 100644
--- a/nixos/modules/virtualisation/oci-containers.nix
+++ b/nixos/modules/virtualisation/oci-containers.nix
@@ -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;