Subject: Bisected regression: database container cookbook example fails to start

From: "Owen T. Heisler" <[email-masked]>
Date: Mon, 5 May 2025 15:51:43 -0500

Hello,

Since commit a57ed987ffd1452ba5a4d70feb54893e99b8e076 ("linux-container:
Lock mounts by default."), the container resulting from `guix system
container` fails to start.

```console
$ guix time-machine --commit=a57ed987ffd1452ba5a4d70feb54893e99b8e076 --
system container db.scm
...
/gnu/store/63af016iyah8k94vv2k42c7hn9a545dp-run-container
$ sudo /gnu/store/63af016iyah8k94vv2k42c7hn9a545dp-run-container
guile: warning: failed to install locale
Backtrace:
           7 (primitive-load "/gnu/store/63af016iyah8k94vv2k42c7hn9a?")
In gnu/build/linux-container.scm:
    368:8  6 (call-with-temporary-directory #<procedure 7fcf0add9af0?>)
   476:16  5 (_ "/tmp/guix-directory.tNBEMR")
     62:6  4 (call-with-clean-exit #<procedure 7fcf0b542b80 at gnu/b?>)
   323:22  3 (_)
    215:2  2 (initialize-user-namespace 1 65536 #:host-uid _ # _ # _ ?)
In ice-9/ports.scm:
    435:6  1 (call-with-output-file _ _ #:binary _ #:encoding _)
In unknown file:
           0 (close-port #<output: /proc/1/uid_map 6>)

ERROR: In procedure close-port:
In procedure fport_write: Operation not permitted
system container is running as PID #f
Run 'sudo guix container exec #f /run/current-system/profile/bin/bash
--login'
or run 'sudo nsenter -a -t #f' to get a shell into it.

Backtrace:
           3 (primitive-load "/gnu/store/63af016iyah8k94vv2k42c7hn9a?")
In gnu/build/linux-container.scm:
    368:8  2 (call-with-temporary-directory #<procedure 7fcf0add9af0?>)
    485:7  1 (_ "/tmp/guix-directory.tNBEMR")
In unknown file:
           0 (waitpid #f #<undefined>)

ERROR: In procedure waitpid:
Wrong type (expecting exact integer): #f
```

Using the following `db.scm` from
<https://guix.gnu.org/cookbook/en/html_node/A-Database-Container.html>
example with no changes:

```scm
(use-modules (gnu))
(use-package-modules databases)
(use-service-modules databases)

(operating-system
  (host-name "container")
  (timezone "Europe/Berlin")
  (file-systems (cons (file-system
                        (device (file-system-label "does-not-matter"))
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems))
  (bootloader (bootloader-configuration
               (bootloader grub-bootloader)
               (targets '("/dev/sdX"))))
  (services
   (cons* (service postgresql-service-type
                   (postgresql-configuration
                    (postgresql postgresql-14)
                    (config-file
                     (postgresql-config-file
                      (log-destination "stderr")
                      (hba-file
                       (plain-file "pg_hba.conf"
                                   "\
local	all	all			trust
host	all	all	10.0.0.1/32 	trust"))
                      (extra-config
                       '(("listen_addresses" "*")
                         ("log_directory"    "/var/log/postgresql")))))))
          (service postgresql-role-service-type
                   (postgresql-role-configuration
                    (roles
                     (list (postgresql-role
                            (name "test")
                            (create-database? #t))))))
          %base-services)))
```

Thanks,
Owen