Subject: Re: bug#61627: Cannot start a container built with `guix system container --network'.

From: Bruno Victal <[email-masked]>
Date: Mon, 20 Mar 2023 17:46:23 +0000

Hi,

On 2023-02-19 15:29, Pierre Langlois wrote:
> 
> Pierre Langlois <[email-masked]> writes:
> 
> Digging into the container script code, I think the reason is that when
> sharing the network, it's supposed to remove any network-related
> services from the containerized operating system. And it's not aware of
> the new hosts-service-type. The following diff seems to fix the issue:
> 
> --8<---------------cut here---------------start------------->8---
> diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm
> index c2fd55d48e..9190d013bc 100644
> --- a/gnu/system/linux-container.scm
> +++ b/gnu/system/linux-container.scm
> @@ -49,9 +49,12 @@ (define* (container-essential-services os #:key shared-network?)
>    (define base
>      (remove (lambda (service)
>                (memq (service-kind service)
> -                    (list (service-kind %linux-bare-metal-service)
> -                          firmware-service-type
> -                          system-service-type)))
> +                    (cons* (service-kind %linux-bare-metal-service)
> +                           firmware-service-type
> +                           system-service-type
> +                           (if shared-network?
> +                               (list hosts-service-type)
> +                               '()))))
>              (operating-system-default-essential-services os)))
> 
>    (cons (service system-service-type
> --8<---------------cut here---------------end--------------->8---
> 
> I wonder if this is a full fix though, I see that we also remove network
> related configuration files, using `%network-configuration-files', and I
> wonder if "/etc/hosts" is still supposed to be there?
> 
> --8<---------------cut here---------------start------------->8---
> (define %network-configuration-files
>   ;; List of essential network configuration files.
>   '("/etc/resolv.conf"
>     "/etc/nsswitch.conf"
>     "/etc/services"
>     "/etc/hosts"))
> --8<---------------cut here---------------end--------------->8---

/etc/hosts is created by hosts-service-type, so if you remove that service
it shouldn't be present anymore.

Cheers,
Bruno