From 08ac06edbaaeccb4677adca396c30a8f88cb9c92 Mon Sep 17 00:00:00 2001 From: Atemu Date: Fri, 14 Feb 2020 23:57:31 +0100 Subject: [PATCH] docker-containers: Add autoStart option (#76480) This option allows the user to control whether or not the docker container is automatically started on boot. The previous default behavior (true) is preserved --- nixos/modules/virtualisation/docker-containers.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/docker-containers.nix b/nixos/modules/virtualisation/docker-containers.nix index 216ba2c733f..cae39a56f52 100644 --- a/nixos/modules/virtualisation/docker-containers.nix +++ b/nixos/modules/virtualisation/docker-containers.nix @@ -192,13 +192,22 @@ let ["--network=host"] ''; }; + + autoStart = mkOption { + type = types.bool; + default = true; + description = '' + When enabled, the container is automatically started on boot. + If this option is set to false, the container has to be started on-demand via its service. + ''; + }; }; }; mkService = name: container: let mkAfter = map (x: "docker-${x}.service") container.dependsOn; in rec { - wantedBy = [ "multi-user.target" ]; + wantedBy = [] ++ optional (container.autoStart) "multi-user.target"; after = [ "docker.service" "docker.socket" ] ++ mkAfter; requires = after;