linux-container: ‘containerized-operating-system’ provides ‘loopback’ service.

Fixes #420.

Previously, in systems produced by ‘guix system container’, the
‘loopback’ Shepherd service would fail to start with EEXIST, because the
“lo” interface already exists in the container.  This commit provides a
fake ‘loopback’ Shepherd service that does nothing.

* gnu/system/linux-container.scm (dummy-networking-service-type): Change
to honor its configuration value.
(containerized-operating-system)[services-to-drop]: Add
‘static-networking-service-type’ in the non-‘shared-network?’ case.
[services-to-add]: Add ‘dummy-networking-service-type’ for loopback in
the non-‘shared-network?’ case.

Reported-by: Antonio Carlos Padoan Junior <acpadoanjr@yahoo.com.br>
Change-Id: I326b5f3b5e08f67b6613c186497c44b1e887b02e
This commit is contained in:
Ludovic Courtès 2025-06-04 17:01:23 +02:00
parent 1ed9af7586
commit ed5988f0d2
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -78,12 +78,13 @@ from OS that are needed on the bare metal and not in a container."
(define dummy-networking-service-type (define dummy-networking-service-type
(shepherd-service-type (shepherd-service-type
'dummy-networking 'dummy-networking
(const (shepherd-service (lambda (provision)
(documentation "Provide loopback and networking without actually (shepherd-service
(documentation "Provide loopback and networking without actually
doing anything.") doing anything.")
(provision '(loopback networking)) (provision provision)
(start #~(const #t)))) (start #~(const #t))))
#f '(loopback networking)
(description "Provide loopback and networking without actually doing (description "Provide loopback and networking without actually doing
anything. This service is used by guest systems running in containers, where anything. This service is used by guest systems running in containers, where
networking support is provided by the host."))) networking support is provided by the host.")))
@ -135,7 +136,7 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
dhcp-client-service-type dhcp-client-service-type
network-manager-service-type network-manager-service-type
connman-service-type) connman-service-type)
(list)))) (list static-networking-service-type)))) ;loopback
(define services-to-add (define services-to-add
;; Many Guix services depend on a 'networking' shepherd ;; Many Guix services depend on a 'networking' shepherd
@ -143,8 +144,10 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
;; service when we are sure that networking is already set up ;; service when we are sure that networking is already set up
;; in the host and can be used. That prevents double setup. ;; in the host and can be used. That prevents double setup.
(if shared-network? (if shared-network?
(list (service dummy-networking-service-type)) (list (service dummy-networking-service-type
'())) '(loopback networking)))
(list (service dummy-networking-service-type
'(loopback)))))
(define os-with-base-essential-services (define os-with-base-essential-services
(operating-system (operating-system