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
This commit is contained in:
parent
ce8d1c2adf
commit
08ac06edba
@ -192,13 +192,22 @@ let
|
|||||||
["--network=host"]
|
["--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
|
mkService = name: container: let
|
||||||
mkAfter = map (x: "docker-${x}.service") container.dependsOn;
|
mkAfter = map (x: "docker-${x}.service") container.dependsOn;
|
||||||
in rec {
|
in rec {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [] ++ optional (container.autoStart) "multi-user.target";
|
||||||
after = [ "docker.service" "docker.socket" ] ++ mkAfter;
|
after = [ "docker.service" "docker.socket" ] ++ mkAfter;
|
||||||
requires = after;
|
requires = after;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user