mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 20:25:32 +03:00
nixos/oci-containers: add autoRemoveOnStop option
Adds the autoRemoveOnStop option to allow stopped or killed containers to stay around after stop. Default behaviour remains the same.
This commit is contained in:
parent
417b73156f
commit
542a053b32
1 changed files with 9 additions and 1 deletions
|
@ -381,6 +381,14 @@ let
|
|||
'';
|
||||
};
|
||||
|
||||
autoRemoveOnStop = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Automatically remove the container when it is stopped or killed
|
||||
'';
|
||||
};
|
||||
|
||||
networks = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [ ];
|
||||
|
@ -468,7 +476,6 @@ let
|
|||
++ map escapeShellArg container.preRunExtraOptions
|
||||
++ [
|
||||
"run"
|
||||
"--rm"
|
||||
"--name=${escapedName}"
|
||||
"--log-driver=${container.log-driver}"
|
||||
]
|
||||
|
@ -489,6 +496,7 @@ let
|
|||
++ (mapAttrsToList (k: v: "-l ${escapeShellArg k}=${escapeShellArg v}") container.labels)
|
||||
++ optional (container.workdir != null) "-w ${escapeShellArg container.workdir}"
|
||||
++ optional (container.privileged) "--privileged"
|
||||
++ optional (container.autoRemoveOnStop) "--rm"
|
||||
++ mapAttrsToList (k: _: "--cap-add=${escapeShellArg k}") (
|
||||
filterAttrs (_: v: v == true) container.capabilities
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue