summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Leidi <goodoldpaul@autistici.org>2024-06-11 22:04:57 +0200
committerGuix Patches Tester <>2024-06-11 23:17:09 +0200
commitb076d80c38ee4065da407b8e9bc2ff402441be58 (patch)
treeaa1cf19633ffceb25aabbc45ef4d7146f3ee3ab0
parent47620e300079e701dc565e23293f442b4cc81df1 (diff)
downloadguix-patches-b076d80c38ee4065da407b8e9bc2ff402441be58.tar
guix-patches-b076d80c38ee4065da407b8e9bc2ff402441be58.tar.gz
gnu: docker: Allow setting Shepherd log-file in oci-container-configuration.
* gnu/services/docker.scm (oci-container-configuration) [log-file]: New field; (oci-container-shepherd-service): use it. * doc/guix.texi: Document it. Change-Id: Icad29ac6342b6f5bafc0d9be13a93cee99674185
-rw-r--r--doc/guix.texi5
-rw-r--r--gnu/services/docker.scm19
2 files changed, 20 insertions, 4 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 5a06d7cdc5..40296fcd5f 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -40698,6 +40698,11 @@ Set the name of the provisioned Shepherd service.
Set additional Shepherd services dependencies to the provisioned
Shepherd service.
+@item @code{log-file} (default: @code{""}) (type: string)
+When @code{log-file} is set, it names the file to which the service's
+standard output and standard error are redirected. @code{log-file} is created
+if it does not exist, otherwise it is appended to.
+
@item @code{network} (default: @code{""}) (type: string)
Set a Docker network for the spawned container.
diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm
index cc1201508c..678e8b1139 100644
--- a/gnu/services/docker.scm
+++ b/gnu/services/docker.scm
@@ -74,6 +74,7 @@
oci-container-configuration-image
oci-container-configuration-provision
oci-container-configuration-requirement
+ oci-container-configuration-log-file
oci-container-configuration-network
oci-container-configuration-ports
oci-container-configuration-volumes
@@ -461,6 +462,11 @@ Engine, and follow the usual format
(list-of-symbols '())
"Set additional Shepherd services dependencies to the provisioned Shepherd
service.")
+ (log-file
+ (maybe-string)
+ "When @code{log-file} is set, it names the file to which the service’s
+standard output and standard error are redirected. @code{log-file} is created
+if it does not exist, otherwise it is appended to.")
(network
(maybe-string)
"Set a Docker network for the spawned container.")
@@ -669,12 +675,16 @@ operating-system, gexp or file-like records but ~a was found")
(host-environment
(oci-container-configuration-host-environment config))
(command (oci-container-configuration-command config))
+ (log-file (oci-container-configuration-log-file config))
(provision (oci-container-configuration-provision config))
(requirement (oci-container-configuration-requirement config))
(image (oci-container-configuration-image config))
(image-reference (oci-image-reference image))
(options (oci-container-configuration->options config))
(name (guess-name provision image))
+ (loader (if (oci-image? image)
+ (%oci-image-loader name image image-reference)
+ #f))
(extra-arguments
(oci-container-configuration-extra-arguments config)))
@@ -687,10 +697,8 @@ operating-system, gexp or file-like records but ~a was found")
(if (oci-image? image) name image) "."))
(start
#~(lambda ()
- #$@(if (oci-image? image)
- #~((invoke #$(%oci-image-loader
- name image image-reference)))
- #~())
+ (when #$(oci-image? image)
+ (invoke #$loader))
(fork+exec-command
;; docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
(list #$docker "run" "--rm" "--name" #$name
@@ -698,6 +706,9 @@ operating-system, gexp or file-like records but ~a was found")
#$image-reference #$@command)
#:user #$user
#:group #$group
+ #$@(if (maybe-value-set? log-file)
+ (list #:log-file log-file)
+ '())
#:environment-variables
(list #$@host-environment))))
(stop