summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtemu <atemu.main@gmail.com>2020-02-14 23:57:31 +0100
committerGitHub <noreply@github.com>2020-02-15 00:57:31 +0200
commit08ac06edbaaeccb4677adca396c30a8f88cb9c92 (patch)
tree12e374c71c9c32270b8b08b1f3233be9a790f89d
parentce8d1c2adfcbc9dd2dd7ad5aa801b6d0886408e4 (diff)
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
-rw-r--r--nixos/modules/virtualisation/docker-containers.nix11
1 files changed, 10 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/docker-containers.nix b/nixos/modules/virtualisation/docker-containers.nix
index 216ba2c733fc..cae39a56f52f 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;