On 5/11/25 00:03, Naranden wrote:
> Here are some more details. I am experimenting with using guix to
> provide a multi-container (or similar) reproducible environment from
> local development (with something like guix system vm or container) to
> deployment (with guix deploy). I am wondering about writing various
> container operating-system definitions, adding those as services to a
> host operating-system definition, and then using guix deploy to deploy
> the host operating-system.
In case anyone is interested, I was able to get something *like* this to
work with Docker containers: I can define an operating-system that is
then included as a service in a parent operating-system.
With Docker involved here, there is extra time and disk space used
bundling and extracting the OCI image. Guix bundles the operating-system
into an image.tar.gz and then the parent operating-system tells Docker
to load that image from the store.
I suppose there must be some way to make this work like Guix system
containers, where everything the container needs is loaded from the
store rather than through Docker.
Write the below to `test.scm` and run `$(guix system --no-graphic
--image-size=7G --persistent vm test.scm) -m 1G -nic user`. Once the VM
has booted, run `herd status docker-container-image`; it will be stuck
on "starting..." until Docker finishes loading the image.
```
(use-modules (gnu))
(use-package-modules databases)
(use-service-modules databases desktop docker networking web)
(define nginx-root-dir
(file-union "nginx-root"
`(("index.html" ,(plain-file "index.html"
"<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body>
<h1>Welcome to nginx!</h1>
</body>
</html>")))))
(define container-os
(operating-system
(host-name "container")
(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 nginx-service-type
(nginx-configuration
(server-blocks
(list (nginx-server-configuration
(listen '("*:80"))
(root nginx-root-dir))))))
%base-services))))
(define parent-os
(operating-system
(host-name "parent")
(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 containerd-service-type)
(service docker-service-type)
(service elogind-service-type)
(service oci-container-service-type
(list
(oci-container-configuration
(ports '(("8080" . "80")))
(image
(oci-image
(repository "container-image")
(value container-os))))))
(service static-networking-service-type
(list %qemu-static-networking))
%base-services))))
parent-os
```
Thanks,
Naranden