Merge pull request #141549 from bobvanderlinden/docker-daemon-config

nixos/docker: add daemon.settings option
This commit is contained in:
Robert Hensing 2021-12-20 12:46:48 +01:00 committed by GitHub
commit f0fe5e9ba0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 7 deletions

View file

@ -109,6 +109,14 @@
<literal>writers.writePyPy2</literal> needs to be used. <literal>writers.writePyPy2</literal> needs to be used.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
If you previously used
<literal>/etc/docker/daemon.json</literal>, you need to
incorporate the changes into the new option
<literal>virtualisation.docker.daemon.settings</literal>.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
<section xml:id="sec-release-22.05-notable-changes"> <section xml:id="sec-release-22.05-notable-changes">

View file

@ -41,6 +41,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- The `writers.writePython2` and corresponding `writers.writePython2Bin` convenience functions to create executable Python 2 scripts in the store were removed in preparation of removal of the Python 2 interpreter. - The `writers.writePython2` and corresponding `writers.writePython2Bin` convenience functions to create executable Python 2 scripts in the store were removed in preparation of removal of the Python 2 interpreter.
Scripts have to be converted to Python 3 for use with `writers.writePython3` or `writers.writePyPy2` needs to be used. Scripts have to be converted to Python 3 for use with `writers.writePython3` or `writers.writePyPy2` needs to be used.
- If you previously used `/etc/docker/daemon.json`, you need to incorporate the changes into the new option `virtualisation.docker.daemon.settings`.
## Other Notable Changes {#sec-release-22.05-notable-changes} ## Other Notable Changes {#sec-release-22.05-notable-changes}
- The option [services.redis.servers](#opt-services.redis.servers) was added - The option [services.redis.servers](#opt-services.redis.servers) was added

View file

@ -8,7 +8,8 @@ let
cfg = config.virtualisation.docker; cfg = config.virtualisation.docker;
proxy_env = config.networking.proxy.envVars; proxy_env = config.networking.proxy.envVars;
settingsFormat = pkgs.formats.json {};
daemonSettingsFile = settingsFormat.generate "daemon.json" cfg.daemon.settings;
in in
{ {
@ -52,6 +53,20 @@ in
''; '';
}; };
daemon.settings =
mkOption {
type = settingsFormat.type;
default = { };
example = {
ipv6 = true;
"fixed-cidr-v6" = "fd00::/80";
};
description = ''
Configuration for docker daemon. The attributes are serialized to JSON used as daemon.conf.
See https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file
'';
};
enableNvidia = enableNvidia =
mkOption { mkOption {
type = types.bool; type = types.bool;
@ -171,12 +186,7 @@ in
"" ""
'' ''
${cfg.package}/bin/dockerd \ ${cfg.package}/bin/dockerd \
--group=docker \ --config-file=${daemonSettingsFile} \
--host=fd:// \
--log-driver=${cfg.logDriver} \
${optionalString (cfg.storageDriver != null) "--storage-driver=${cfg.storageDriver}"} \
${optionalString cfg.liveRestore "--live-restore" } \
${optionalString cfg.enableNvidia "--add-runtime nvidia=${pkgs.nvidia-docker}/bin/nvidia-container-runtime" } \
${cfg.extraOptions} ${cfg.extraOptions}
'']; ''];
ExecReload=[ ExecReload=[
@ -219,6 +229,19 @@ in
{ assertion = cfg.enableNvidia -> config.hardware.opengl.driSupport32Bit or false; { assertion = cfg.enableNvidia -> config.hardware.opengl.driSupport32Bit or false;
message = "Option enableNvidia requires 32bit support libraries"; message = "Option enableNvidia requires 32bit support libraries";
}]; }];
virtualisation.docker.daemon.settings = {
group = "docker";
hosts = [ "fd://" ];
log-driver = mkDefault cfg.logDriver;
storage-driver = mkIf (cfg.storageDriver != null) (mkDefault cfg.storageDriver);
live-restore = mkDefault cfg.liveRestore;
runtimes = mkIf cfg.enableNvidia {
nvidia = {
path = "${pkgs.nvidia-docker}/bin/nvidia-container-runtime";
};
};
};
} }
]); ]);