services: docker: Add 'environment-variables' configuration field.

* gnu/services/docker.scm (docker-configuration):  Add the field
(docker-shepherd-service): Pass the list of defined variables to
make-forkexec-constructor.
* doc/guix.texi (Miscellaneous Services): Update doc.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Alexey Abramov 2021-11-04 07:48:09 +01:00 committed by Ludovic Courtès
parent 6bffa13040
commit 4ace645506
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 17 additions and 0 deletions

View file

@ -33229,6 +33229,17 @@ Enable or disable debug output.
@item @code{enable-iptables?} (default @code{#t}) @item @code{enable-iptables?} (default @code{#t})
Enable or disable the addition of iptables rules. Enable or disable the addition of iptables rules.
@item @code{environment-variables} (default: @code{()})
List of environment variables to set for @command{dockerd}.
This must be a list of strings where each string has the form
@samp{@var{key}=@var{value}} as in this example:
@lisp
(list "LANGUAGE=eo:ca:eu"
"TMPDIR=/tmp/dockerd")
@end lisp
@end table @end table
@end deftp @end deftp

View file

@ -62,6 +62,9 @@ (define-configuration docker-configuration
(enable-iptables? (enable-iptables?
(boolean #t) (boolean #t)
"Enable addition of iptables rules (enabled by default).") "Enable addition of iptables rules (enabled by default).")
(environment-variables
(list '())
"Environment variables to set for dockerd")
(no-serialization)) (no-serialization))
(define %docker-accounts (define %docker-accounts
@ -102,6 +105,7 @@ (define (docker-shepherd-service config)
(let* ((docker (docker-configuration-docker config)) (let* ((docker (docker-configuration-docker config))
(enable-proxy? (docker-configuration-enable-proxy? config)) (enable-proxy? (docker-configuration-enable-proxy? config))
(enable-iptables? (docker-configuration-enable-iptables? config)) (enable-iptables? (docker-configuration-enable-iptables? config))
(environment-variables (docker-configuration-environment-variables config))
(proxy (docker-configuration-proxy config)) (proxy (docker-configuration-proxy config))
(debug? (docker-configuration-debug? config))) (debug? (docker-configuration-debug? config)))
(shepherd-service (shepherd-service
@ -132,6 +136,8 @@ (define (docker-shepherd-service config)
(if #$enable-iptables? (if #$enable-iptables?
"--iptables" "--iptables"
"--iptables=false")) "--iptables=false"))
#:environment-variables
(list #$@environment-variables)
#:pid-file "/var/run/docker.pid" #:pid-file "/var/run/docker.pid"
#:log-file "/var/log/docker.log")) #:log-file "/var/log/docker.log"))
(stop #~(make-kill-destructor))))) (stop #~(make-kill-destructor)))))