summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorOleg Pykhalov <go.wigust@gmail.com>2024-06-02 09:15:54 +0300
committerOleg Pykhalov <go.wigust@gmail.com>2024-08-04 11:54:50 +0300
commit26638b8e8129aa755586d017677b4cf076bafda6 (patch)
tree88709c2561081805e1dd00ee10a11ebd31996fe9 /gnu
parent4e9c5c601905eb281f2304d0a0d35992c51054cd (diff)
services: containerd: Provision separately from docker service.
containerd can operate independently without relying on Docker for its configuration. * gnu/services/docker.scm (docker-configuration): Deprecate containerd field. (containerd-configuration, containerd-service-type): New variables. (docker-shepherd-service): Use containerd-configuration. Delete duplicated variable binding. Allow to configure environment variables. (docker-service-type): Delete extension with containerd-service-type. * gnu/tests/docker.scm (%docker-os, %oci-os): Add containerd service. (run-docker-test, run-docker-system-test, run-oci-container-test): Run containerd service. * doc/guix.texi (Miscellaneous Services): Document containerd-service-type. Change-Id: Ife0924e50a3e0aa2302d6592dae51ed894600004
Diffstat (limited to 'gnu')
-rw-r--r--gnu/services/docker.scm68
-rw-r--r--gnu/tests/docker.scm46
2 files changed, 92 insertions, 22 deletions
diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm
index 6f91c9659b1..1963f3c4bd6 100644
--- a/gnu/services/docker.scm
+++ b/gnu/services/docker.scm
@@ -49,7 +49,9 @@
49 #:use-module (ice-9 format) 49 #:use-module (ice-9 format)
50 #:use-module (ice-9 match) 50 #:use-module (ice-9 match)
51 51
52 #:export (docker-configuration 52 #:export (containerd-configuration
53 containerd-service-type
54 docker-configuration
53 docker-service-type 55 docker-service-type
54 singularity-service-type 56 singularity-service-type
55 oci-image 57 oci-image
@@ -99,7 +101,7 @@
99 "Docker client package.") 101 "Docker client package.")
100 (containerd 102 (containerd
101 (file-like containerd) 103 (file-like containerd)
102 "containerd package.") 104 "Deprecated. Do not use.")
103 (proxy 105 (proxy
104 (file-like docker-libnetwork-cmd-proxy) 106 (file-like docker-libnetwork-cmd-proxy)
105 "The proxy package to support inter-container and outside-container 107 "The proxy package to support inter-container and outside-container
@@ -121,6 +123,18 @@ loop-back communications.")
121 "JSON configuration file to pass to dockerd") 123 "JSON configuration file to pass to dockerd")
122 (no-serialization)) 124 (no-serialization))
123 125
126(define-configuration containerd-configuration
127 (containerd
128 (file-like containerd)
129 "containerd package.")
130 (debug?
131 (boolean #f)
132 "Enable or disable debug output.")
133 (environment-variables
134 (list '())
135 "Environment variables to set for containerd.")
136 (no-serialization))
137
124(define %docker-accounts 138(define %docker-accounts
125 (list (user-group (name "docker") (system? #t)))) 139 (list (user-group (name "docker") (system? #t))))
126 140
@@ -138,24 +152,37 @@ loop-back communications.")
138 (mkdir-p #$state-dir)))) 152 (mkdir-p #$state-dir))))
139 153
140(define (containerd-shepherd-service config) 154(define (containerd-shepherd-service config)
141 (let* ((package (docker-configuration-containerd config)) 155 (match-record config <containerd-configuration>
142 (debug? (docker-configuration-debug? config)) 156 (containerd debug? environment-variables)
143 (containerd (docker-configuration-containerd config)))
144 (shepherd-service 157 (shepherd-service
145 (documentation "containerd daemon.") 158 (documentation "containerd daemon.")
146 (provision '(containerd)) 159 (provision '(containerd))
147 (start #~(make-forkexec-constructor 160 (start #~(make-forkexec-constructor
148 (list (string-append #$package "/bin/containerd") 161 (list (string-append #$containerd "/bin/containerd")
149 #$@(if debug? 162 #$@(if debug?
150 '("--log-level=debug") 163 '("--log-level=debug")
151 '())) 164 '()))
152 ;; For finding containerd-shim binary. 165 ;; For finding containerd-shim binary.
153 #:environment-variables 166 #:environment-variables
154 (list (string-append "PATH=" #$containerd "/bin")) 167 (list #$@environment-variables
155 #:pid-file "/run/containerd/containerd.pid" 168 (string-append "PATH=" #$containerd "/bin"))
156 #:pid-file-timeout 300 169 #:pid-file "/run/containerd/containerd.pid"
157 #:log-file "/var/log/containerd.log")) 170 #:pid-file-timeout 300
158 (stop #~(make-kill-destructor))))) 171 #:log-file "/var/log/containerd.log"))
172 (stop #~(make-kill-destructor)))))
173
174(define containerd-service-type
175 (service-type (name 'containerd)
176 (description "Run containerd container runtime.")
177 (extensions
178 (list
179 ;; Make sure the 'ctr' command is available.
180 (service-extension profile-service-type
181 (compose list containerd-configuration-containerd))
182 (service-extension shepherd-root-service-type
183 (lambda (config)
184 (list (containerd-shepherd-service config))))))
185 (default-value (containerd-configuration))))
159 186
160(define (docker-shepherd-service config) 187(define (docker-shepherd-service config)
161 (let* ((docker (docker-configuration-docker config)) 188 (let* ((docker (docker-configuration-docker config))
@@ -212,8 +239,7 @@ bundles in Docker containers.")
212 %docker-activation) 239 %docker-activation)
213 (service-extension shepherd-root-service-type 240 (service-extension shepherd-root-service-type
214 (lambda (config) 241 (lambda (config)
215 (list (containerd-shepherd-service config) 242 (list (docker-shepherd-service config))))
216 (docker-shepherd-service config))))
217 (service-extension account-service-type 243 (service-extension account-service-type
218 (const %docker-accounts)))) 244 (const %docker-accounts))))
219 (default-value (docker-configuration)))) 245 (default-value (docker-configuration))))
diff --git a/gnu/tests/docker.scm b/gnu/tests/docker.scm
index d550136b4aa..46c886580c3 100644
--- a/gnu/tests/docker.scm
+++ b/gnu/tests/docker.scm
@@ -54,6 +54,7 @@
54 (service dbus-root-service-type) 54 (service dbus-root-service-type)
55 (service polkit-service-type) 55 (service polkit-service-type)
56 (service elogind-service-type) 56 (service elogind-service-type)
57 (service containerd-service-type)
57 (service docker-service-type))) 58 (service docker-service-type)))
58 59
59(define (run-docker-test docker-tarball) 60(define (run-docker-test docker-tarball)
@@ -88,7 +89,21 @@ inside %DOCKER-OS."
88 (test-runner-current (system-test-runner #$output)) 89 (test-runner-current (system-test-runner #$output))
89 (test-begin "docker") 90 (test-begin "docker")
90 91
91 (test-assert "service running" 92 (test-assert "containerd service running"
93 (marionette-eval
94 '(begin
95 (use-modules (gnu services herd))
96 (match (start-service 'containerd)
97 (#f #f)
98 (('service response-parts ...)
99 (match (assq-ref response-parts 'running)
100 ((pid) (number? pid))))))
101 marionette))
102
103 (test-assert "containerd PID file present"
104 (wait-for-file "/run/containerd/containerd.pid" marionette))
105
106 (test-assert "dockerd service running"
92 (marionette-eval 107 (marionette-eval
93 '(begin 108 '(begin
94 (use-modules (gnu services herd)) 109 (use-modules (gnu services herd))
@@ -234,6 +249,20 @@ inside %DOCKER-OS."
234 (test-runner-current (system-test-runner #$output)) 249 (test-runner-current (system-test-runner #$output))
235 (test-begin "docker") 250 (test-begin "docker")
236 251
252 (test-assert "containerd service running"
253 (marionette-eval
254 '(begin
255 (use-modules (gnu services herd))
256 (match (start-service 'containerd)
257 (#f #f)
258 (('service response-parts ...)
259 (match (assq-ref response-parts 'running)
260 ((pid) (number? pid))))))
261 marionette))
262
263 (test-assert "containerd PID file present"
264 (wait-for-file "/run/containerd/containerd.pid" marionette))
265
237 (test-assert "service running" 266 (test-assert "service running"
238 (marionette-eval 267 (marionette-eval
239 '(begin 268 '(begin
@@ -327,6 +356,7 @@ docker-image} inside Docker.")
327 (service dbus-root-service-type) 356 (service dbus-root-service-type)
328 (service polkit-service-type) 357 (service polkit-service-type)
329 (service elogind-service-type) 358 (service elogind-service-type)
359 (service containerd-service-type)
330 (service docker-service-type) 360 (service docker-service-type)
331 (extra-special-file "/shared.txt" 361 (extra-special-file "/shared.txt"
332 (plain-file "shared.txt" "hello")) 362 (plain-file "shared.txt" "hello"))
@@ -384,6 +414,20 @@ docker-image} inside Docker.")
384 (test-runner-current (system-test-runner #$output)) 414 (test-runner-current (system-test-runner #$output))
385 (test-begin "oci-container") 415 (test-begin "oci-container")
386 416
417 (test-assert "containerd service running"
418 (marionette-eval
419 '(begin
420 (use-modules (gnu services herd))
421 (match (start-service 'containerd)
422 (#f #f)
423 (('service response-parts ...)
424 (match (assq-ref response-parts 'running)
425 ((pid) (number? pid))))))
426 marionette))
427
428 (test-assert "containerd PID file present"
429 (wait-for-file "/run/containerd/containerd.pid" marionette))
430
387 (test-assert "dockerd running" 431 (test-assert "dockerd running"
388 (marionette-eval 432 (marionette-eval
389 '(begin 433 '(begin