services: oci-container: Allow setting Shepherd auto-start? in oci-container-configuration.

* gnu/services/docker.scm (oci-container-configuration)
[auto-start?]: New field.
(oci-container-shepherd-service): use it.

* doc/guix.texi: Document it.

Change-Id: Id093d93effbbec3e1be757f8be83cf5f62eaeda7
Signed-off-by: Zheng Junjie <zhengjunjie@iscas.ac.cn>
This commit is contained in:
Giacomo Leidi via Guix-patches via 2024-06-11 22:04:58 +02:00 committed by Zheng Junjie
parent 30ba86cb71
commit 7d91bd4530
No known key found for this signature in database
GPG key ID: 3B5AA993E1A2DFF0
2 changed files with 12 additions and 0 deletions

View file

@ -40890,6 +40890,10 @@ 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{auto-start?} (default: @code{#t}) (type: boolean)
Whether this service should be started automatically by the Shepherd. If it
is @code{#f} the service has to be started manually with @command{herd start}.
@item @code{network} (default: @code{""}) (type: string)
Set a Docker network for the spawned container.

View file

@ -75,6 +75,7 @@ (define-module (gnu services docker)
oci-container-configuration-provision
oci-container-configuration-requirement
oci-container-configuration-log-file
oci-container-configuration-auto-start?
oci-container-configuration-network
oci-container-configuration-ports
oci-container-configuration-volumes
@ -467,6 +468,10 @@ (define-configuration/no-serialization oci-container-configuration
"When @code{log-file} is set, it names the file to which the services
standard output and standard error are redirected. @code{log-file} is created
if it does not exist, otherwise it is appended to.")
(auto-start?
(boolean #t)
"Whether this service should be started automatically by the Shepherd. If it
is @code{#f} the service has to be started manually with @command{herd start}.")
(network
(maybe-string)
"Set a Docker network for the spawned container.")
@ -670,6 +675,8 @@ (define (guess-name name image)
(oci-image-repository image))))))
(let* ((docker (file-append docker-cli "/bin/docker"))
(auto-start?
(oci-container-configuration-auto-start? config))
(user (oci-container-configuration-user config))
(group (oci-container-configuration-group config))
(host-environment
@ -688,6 +695,7 @@ (define (guess-name name image)
(shepherd-service (provision `(,(string->symbol name)))
(requirement `(dockerd user-processes ,@requirement))
(respawn? #f)
(auto-start? auto-start?)
(documentation
(string-append
"Docker backed Shepherd service for "