docker: fix socket permissions
Docker socket is world writable. This means any user on the system is
able to invoke docker command. (Which is equal to having a root access
to the machine.)
This commit makes socket group-writable and owned by docker group.
Inspired by
https://github.com/docker/docker/blob/master/contrib/init/systemd/docker.socket
commitfa4fe7110566d8370983fa81f2b04a833339236d
authorAlexey Shmalko <rasen.dubi@gmail.com>
dateMon 27 Mar 2017, 16:11 (10 years ago)
parenta29d0df
nixos/modules/virtualisation/docker.nix+11−1
@@ -126,7 +126,17 @@ in
126126
127127 path = [ pkgs.kmod ] ++ (optional (cfg.storageDriver == "zfs") pkgs.zfs);
128128 };
129− systemd.sockets.docker.socketConfig.ListenStream = cfg.listenOptions;
129+
130+ systemd.sockets.docker = {
131+ description = "Docker Socket for the API";
132+ wantedBy = [ "sockets.target" ];
133+ socketConfig = {
134+ ListenStream = cfg.listenOptions;
135+ SocketMode = "0660";
136+ SocketUser = "root";
137+ SocketGroup = "docker";
138+ };
139+ };
130140 }
131141 ]);
132142