gnu: services: docker: Add a debug? parameter.

* gnu/services/docker.scm (docker-configuration): Add a debug? field.
(containerd-shepherd-service): Pass the "--log-level=debug" argument when
DEBUG? is true.
(docker-shepherd-service): Pass the "--debug" and "--log-level=debug"
arguments when DEBUG? is true.
* doc/guix.texi (Miscellaneous Services): Update doc.
This commit is contained in:
Maxim Cournoyer 2020-06-01 20:54:40 -04:00
parent 2f49007dd0
commit 7c9be7b7cb
No known key found for this signature in database
GPG key ID: 1260E46482E63562
2 changed files with 25 additions and 4 deletions

View file

@ -26287,6 +26287,15 @@ The Docker package to use.
@item @code{containerd} (default: @var{containerd}) @item @code{containerd} (default: @var{containerd})
The Containerd package to use. The Containerd package to use.
@item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
The Docker user-land networking proxy package to use.
@item @code{enable-proxy?} (default @code{#f})
Enable or disable the use of the Docker user-land networking proxy.
@item @code{debug?} (default @code{#f})
Enable or disable debug output.
@end table @end table
@end deftp @end deftp

View file

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org> ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net> ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -52,7 +53,10 @@ (define-configuration docker-configuration
loop-back communications.") loop-back communications.")
(enable-proxy? (enable-proxy?
(boolean #t) (boolean #t)
"Enable or disable the user-land proxy (enabled by default).")) "Enable or disable the user-land proxy (enabled by default).")
(debug?
(boolean #f)
"Enable or disable debug output."))
(define %docker-accounts (define %docker-accounts
(list (user-group (name "docker") (system? #t)))) (list (user-group (name "docker") (system? #t))))
@ -71,19 +75,24 @@ (define (%docker-activation config)
(mkdir-p #$state-dir)))) (mkdir-p #$state-dir))))
(define (containerd-shepherd-service config) (define (containerd-shepherd-service config)
(let* ((package (docker-configuration-containerd config))) (let* ((package (docker-configuration-containerd config))
(debug? (docker-configuration-debug? config)))
(shepherd-service (shepherd-service
(documentation "containerd daemon.") (documentation "containerd daemon.")
(provision '(containerd)) (provision '(containerd))
(start #~(make-forkexec-constructor (start #~(make-forkexec-constructor
(list (string-append #$package "/bin/containerd")) (list (string-append #$package "/bin/containerd")
#$@(if debug?
'("--log-level=debug")
'()))
#:log-file "/var/log/containerd.log")) #:log-file "/var/log/containerd.log"))
(stop #~(make-kill-destructor))))) (stop #~(make-kill-destructor)))))
(define (docker-shepherd-service config) (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))
(proxy (docker-configuration-proxy config))) (proxy (docker-configuration-proxy config))
(debug? (docker-configuration-debug? config)))
(shepherd-service (shepherd-service
(documentation "Docker daemon.") (documentation "Docker daemon.")
(provision '(dockerd)) (provision '(dockerd))
@ -101,6 +110,9 @@ (define (docker-shepherd-service config)
(start #~(make-forkexec-constructor (start #~(make-forkexec-constructor
(list (string-append #$docker "/bin/dockerd") (list (string-append #$docker "/bin/dockerd")
"-p" "/var/run/docker.pid" "-p" "/var/run/docker.pid"
#$@(if debug?
'("--debug" "--log-level=debug")
'())
(if #$enable-proxy? "--userland-proxy" "") (if #$enable-proxy? "--userland-proxy" "")
"--userland-proxy-path" (string-append #$proxy "--userland-proxy-path" (string-append #$proxy
"/bin/proxy")) "/bin/proxy"))