services: docker: Add config-file option.

* gnu/services/docker.scm (docker-configuration)[config-file] Add file-like
field.
* doc/guix.texi (Docker Service): Add information about config-file.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
This commit is contained in:
Connor Clark 2023-12-28 23:47:37 -05:00 committed by Mathieu Othacehe
parent c880652fec
commit 2f642b6023
No known key found for this signature in database
GPG key ID: 8354763531769CA6
2 changed files with 14 additions and 1 deletions

View file

@ -39711,6 +39711,9 @@ This must be a list of strings where each string has the form
"TMPDIR=/tmp/dockerd")
@end lisp
@item @code{config-file} (type: maybe-file-like)
JSON configuration file pass to @command{dockerd}.
@end table
@end deftp

View file

@ -61,6 +61,8 @@ (define-module (gnu services docker)
oci-container-service-type
oci-container-shepherd-service))
(define-maybe file-like)
(define-configuration docker-configuration
(docker
(file-like docker)
@ -87,6 +89,9 @@ (define-configuration docker-configuration
(environment-variables
(list '())
"Environment variables to set for dockerd")
(config-file
(maybe-file-like)
"JSON configuration file to pass to dockerd")
(no-serialization))
(define %docker-accounts
@ -131,7 +136,8 @@ (define (docker-shepherd-service config)
(enable-iptables? (docker-configuration-enable-iptables? config))
(environment-variables (docker-configuration-environment-variables config))
(proxy (docker-configuration-proxy config))
(debug? (docker-configuration-debug? config)))
(debug? (docker-configuration-debug? config))
(config-file (docker-configuration-config-file config)))
(shepherd-service
(documentation "Docker daemon.")
(provision '(dockerd))
@ -144,6 +150,10 @@ (define (docker-shepherd-service config)
(start #~(make-forkexec-constructor
(list (string-append #$docker "/bin/dockerd")
"-p" "/var/run/docker.pid"
#$@(if (not (eq? config-file %unset-value))
(list #~(string-append
"--config-file=" #$config-file))
'())
#$@(if debug?
'("--debug" "--log-level=debug")
'())