summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorBob van der Linden <bobvanderlinden@gmail.com>2021-10-13 19:47:37 +0200
committerBob van der Linden <bobvanderlinden@gmail.com>2021-12-19 14:15:18 +0100
commit142a1540d6f1d28f80489212684945ab65a1cee6 (patch)
tree02c8ebe42f566b38b0500daf3f1a05d3ca1d4b76 /nixos
parent93080703881acdfebffd39d9dc5e2031b3efd4db (diff)
downloadnixpkgs-142a1540d6f1d28f80489212684945ab65a1cee6.tar
nixpkgs-142a1540d6f1d28f80489212684945ab65a1cee6.tar.gz
nixpkgs-142a1540d6f1d28f80489212684945ab65a1cee6.tar.bz2
nixpkgs-142a1540d6f1d28f80489212684945ab65a1cee6.tar.lz
nixpkgs-142a1540d6f1d28f80489212684945ab65a1cee6.tar.xz
nixpkgs-142a1540d6f1d28f80489212684945ab65a1cee6.tar.zst
nixpkgs-142a1540d6f1d28f80489212684945ab65a1cee6.zip
nixos/docker: add daemonConfig option
Adds the virtualisation.docker.daemonConfig option that allows
changing Docker daemon settings as done in daemon.conf.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/doc/manual/from_md/release-notes/rl-2205.section.xml8
-rw-r--r--nixos/doc/manual/release-notes/rl-2205.section.md2
-rw-r--r--nixos/modules/virtualisation/docker.nix18
3 files changed, 27 insertions, 1 deletions
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
index 52b2b38061f..e861164920f 100644
--- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
+++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml
@@ -109,6 +109,14 @@
           <literal>writers.writePyPy2</literal> needs to be used.
         </para>
       </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.daemonConfig</literal>.
+        </para>
+      </listitem>
     </itemizedlist>
   </section>
   <section xml:id="sec-release-22.05-notable-changes">
diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md
index 27491e7837c..17e1727dfbc 100644
--- a/nixos/doc/manual/release-notes/rl-2205.section.md
+++ b/nixos/doc/manual/release-notes/rl-2205.section.md
@@ -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.
   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.daemonConfig`.
+
 ## Other Notable Changes {#sec-release-22.05-notable-changes}
 
 - The option [services.redis.servers](#opt-services.redis.servers) was added
diff --git a/nixos/modules/virtualisation/docker.nix b/nixos/modules/virtualisation/docker.nix
index 06858e15030..80bf804cb29 100644
--- a/nixos/modules/virtualisation/docker.nix
+++ b/nixos/modules/virtualisation/docker.nix
@@ -8,7 +8,8 @@ let
 
   cfg = config.virtualisation.docker;
   proxy_env = config.networking.proxy.envVars;
-
+  daemonConfigJson = builtins.toJSON cfg.daemonConfig;
+  daemonConfigFile = pkgs.writeText "daemon.json" daemonConfigJson;
 in
 
 {
@@ -52,6 +53,20 @@ in
           '';
       };
 
+    daemonConfig =
+      mkOption {
+        type = types.anything;
+        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 =
       mkOption {
         type = types.bool;
@@ -173,6 +188,7 @@ in
               ${cfg.package}/bin/dockerd \
                 --group=docker \
                 --host=fd:// \
+                --config-file=${daemonConfigFile} \
                 --log-driver=${cfg.logDriver} \
                 ${optionalString (cfg.storageDriver != null) "--storage-driver=${cfg.storageDriver}"} \
                 ${optionalString cfg.liveRestore "--live-restore" } \