On Sun, 16 Mar 2025 10:02:30 +0100
Denis 'GNUtoo' Carikli <gnu...@cyberdimension.org> wrote:
> There is no official Guix (OCI) container image but you might be able
> to make your own with 'guix system image -t docker [...]', however
> I've no idea if it's trivial or if it requires significant work as
> docker/OCI containers are a bit special (even more so if they don't
> run as root).

I managed to make the command you provided work, but I ran the
container as root. I attached the system scm file and a Makefile as well
to make things easier. Here's how to use them:
> $ make
> [...]
> c4582e6252404ae66e25392d1c08dbee72e859d1f9771b3027f77aef5465a6bd
> $ sudo docker start \
> c4582e6252404ae66e25392d1c08dbee72e859d1f9771b3027f77aef5465a6bd
> [...]
> $ docker exec -ti \
> c4582e6252404ae66e25392d1c08dbee72e859d1f9771b3027f77aef5465a6bd \
> /run/current-system/profile/bin/bash --login
> [...]
> root@guix /# guix shell python python-numpy -- python3
> Python 3.10.7 (main, Jan  1 1970, 00:00:01) [GCC 11.4.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 
> >>> import numpy
> >>> 

However note that I didn't try any of that without running the
container as root.

Denis.
;;; This file is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; This file is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this file.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guix-system)
  #:use-module (gnu)
  #:use-module (gnu bootloader)
  #:use-module (gnu packages bash)
  #:use-module (gnu packages databases)
  #:use-module (gnu services databases))

(define guix-operating-system
  (operating-system
   (host-name "guix")
   (bootloader (bootloader-configuration
		(bootloader grub-bootloader)
		(targets '(file-system-label "Guix_image"))
		(terminal-outputs '(console))))
   (file-systems (append (list (file-system
				(device (file-system-label "Guix_image"))
				(mount-point "/")
				(type "ext4")))
                         %base-file-systems))
   (services
    (list
     ;; Networking
     (service
      static-networking-service-type
      (list
       (static-networking
	(addresses (list))
	(requirement '())
	(provision '(loopback)))))
     ;; Guix
     (service guix-service-type)
     ;; Syslog
     (service syslog-service-type)))))

guix-operating-system
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
SENTINEL =

SYSTEM ?= --system=x86_64-linux

.PHONY: all
all: docker-image.cid

docker-image.tar.gz: guix-system.scm
	install -m 644 `guix system image $(SYSTEM) -t docker guix-system.scm` $@

docker-image.cid: docker-image.tar.gz
	docker load -i docker-image.tar.gz
	docker create \
		--privileged \
		--network=host \
		--cidfile=$@ \
		guix:latest

Attachment: pgpxdmrArRR8_.pgp
Description: OpenPGP digital signature

Reply via email to