linux-container: Remove networking service when network is shared with host.
* gnu/system/linux-container.scm (dummy-networking-service-type): New variable. (containerized-operating-system): If network is shared with host, replace static-networking-service-type with dummy-networking-service-type.
This commit is contained in:
parent
cb13618b6d
commit
b84c4cda04
|
@ -30,6 +30,7 @@
|
||||||
#:use-module (gnu build linux-container)
|
#:use-module (gnu build linux-container)
|
||||||
#:use-module (gnu services)
|
#:use-module (gnu services)
|
||||||
#:use-module (gnu services base)
|
#:use-module (gnu services base)
|
||||||
|
#:use-module (gnu services shepherd)
|
||||||
#:use-module (gnu system)
|
#:use-module (gnu system)
|
||||||
#:use-module (gnu system file-systems)
|
#:use-module (gnu system file-systems)
|
||||||
#:export (system-container
|
#:export (system-container
|
||||||
|
@ -65,6 +66,16 @@ from OS that are needed on the bare metal and not in a container."
|
||||||
files)))
|
files)))
|
||||||
base)))
|
base)))
|
||||||
|
|
||||||
|
(define dummy-networking-service-type
|
||||||
|
(shepherd-service-type
|
||||||
|
'dummy-networking
|
||||||
|
(const (shepherd-service
|
||||||
|
(documentation "Provide loopback and networking without actually
|
||||||
|
doing anything.")
|
||||||
|
(provision '(loopback networking))
|
||||||
|
(start #~(const #t))))
|
||||||
|
#f))
|
||||||
|
|
||||||
(define* (containerized-operating-system os mappings
|
(define* (containerized-operating-system os mappings
|
||||||
#:key
|
#:key
|
||||||
shared-network?
|
shared-network?
|
||||||
|
@ -96,7 +107,8 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
|
||||||
agetty-service-type)
|
agetty-service-type)
|
||||||
;; Remove nscd service if network is shared with the host.
|
;; Remove nscd service if network is shared with the host.
|
||||||
(if shared-network?
|
(if shared-network?
|
||||||
(list nscd-service-type)
|
(list nscd-service-type
|
||||||
|
static-networking-service-type)
|
||||||
(list))))
|
(list))))
|
||||||
|
|
||||||
(operating-system
|
(operating-system
|
||||||
|
@ -105,10 +117,17 @@ containerized OS. EXTRA-FILE-SYSTEMS is a list of file systems to add to OS."
|
||||||
(essential-services (container-essential-services
|
(essential-services (container-essential-services
|
||||||
this-operating-system
|
this-operating-system
|
||||||
#:shared-network? shared-network?))
|
#:shared-network? shared-network?))
|
||||||
(services (remove (lambda (service)
|
(services (append (remove (lambda (service)
|
||||||
(memq (service-kind service)
|
(memq (service-kind service)
|
||||||
useless-services))
|
useless-services))
|
||||||
(operating-system-user-services os)))
|
(operating-system-user-services os))
|
||||||
|
;; Many Guix services depend on a 'networking' shepherd
|
||||||
|
;; service, so make sure to provide a dummy 'networking'
|
||||||
|
;; service when we are sure that networking is already set up
|
||||||
|
;; in the host and can be used. That prevents double setup.
|
||||||
|
(if shared-network?
|
||||||
|
(list (service dummy-networking-service-type))
|
||||||
|
'())))
|
||||||
(file-systems (append (map mapping->fs
|
(file-systems (append (map mapping->fs
|
||||||
(if shared-network?
|
(if shared-network?
|
||||||
(append %network-file-mappings mappings)
|
(append %network-file-mappings mappings)
|
||||||
|
|
Loading…
Reference in New Issue