unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Thompson, David" <dthompson2@worcester.edu>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel <guix-devel@gnu.org>, David Thompson <davet@gnu.org>
Subject: Re: [PATCH 13/15] scripts: system: Add 'container' action.
Date: Mon, 26 Oct 2015 20:24:21 -0400	[thread overview]
Message-ID: <CAJ=RwfYGvC9Dq9=ntcXstPucL2g3qgqRPB4PyU81jajRj-D6Ww@mail.gmail.com> (raw)
In-Reply-To: <87pp44gj11.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

So, It's been awhile. I cleaned up the docs as per your suggestions.
Attaching the updated patch just so someone can give it another look
before I push it.  My "system: container: Update to new service API."
patch must be pushed first, though.

Thanks!

- Dave

[-- Attachment #2: 0001-scripts-system-Add-container-action.patch --]
[-- Type: text/x-diff, Size: 5866 bytes --]

From 5dde31ef51502726a2915cc4faba81f4fadb851c Mon Sep 17 00:00:00 2001
From: David Thompson <davet@gnu.org>
Date: Mon, 8 Jun 2015 09:04:38 -0400
Subject: [PATCH] scripts: system: Add 'container' action.

* guix/scripts/system.scm (show-help): Display 'container' action.
  (system-derivation-for-action, guix-system): Add 'container' case.
  (perform-action): Skip GRUB config generation when building a container.
* doc/guix.texi (Invoking guix system): Document it.
---
 doc/guix.texi                  | 21 +++++++++++++++++++++
 gnu/system/linux-container.scm |  7 ++++++-
 guix/scripts/system.scm        | 19 +++++++++++++------
 3 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 20bf284..3491cfb 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7183,6 +7183,27 @@ using the following command:
 # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
 @end example
 
+@item container
+Return a script to run the operating system declared in @var{file}
+within a container.  Containers are a set of lightweight isolation
+mechanisms provided by the kernel Linux-libre.  Containers are
+substantially less resource-demanding than full virtual machines since
+the kernel, shared objects, and other resources can be shared with the
+host system; this also means they provide thinner isolation.
+
+Currently, the script must be run as root in order to support more than
+a single user and group.  The container shares its store with the host
+system.
+
+As with the @code{vm} action (@pxref{guix system vm}), additional file
+systems to be shared between the host and container can be specified
+using the @option{--share} and @option{--expose} options:
+
+@example
+guix system container my-config.scm \
+   --expose=$HOME --share=$HOME/tmp=/exchange
+@end example
+
 @end table
 
 @var{options} can contain any of the common build options provided by
diff --git a/gnu/system/linux-container.scm b/gnu/system/linux-container.scm
index abe816f..c2eb773 100644
--- a/gnu/system/linux-container.scm
+++ b/gnu/system/linux-container.scm
@@ -108,7 +108,12 @@ that will be shared with the host system."
                 (setenv "TMPDIR" "/tmp")
                 (setenv "GUIX_NEW_SYSTEM" #$os-drv)
                 (for-each mkdir-p '("/run" "/bin" "/etc" "/home" "/var"))
-                (primitive-load (string-append #$os-drv "/boot"))))))
+                (primitive-load (string-append #$os-drv "/boot")))
+              ;; A range of 65536 uid/gids is used to cover 16 bits worth of
+              ;; users and groups, which is sufficient for most cases.
+              ;;
+              ;; See: http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html#--private-users=
+              #:host-uids 65536)))
 
       (gexp->script "run-container" script
                     #:modules '((ice-9 match)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index d847c75..4bf9ac9 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -34,6 +34,7 @@
   #:use-module (gnu build install)
   #:use-module (gnu system)
   #:use-module (gnu system file-systems)
+  #:use-module (gnu system linux-container)
   #:use-module (gnu system vm)
   #:use-module (gnu system grub)
   #:use-module (gnu services)
@@ -406,6 +407,8 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
   (case action
     ((build init reconfigure)
      (operating-system-derivation os))
+    ((container)
+     (container-script os #:mappings mappings))
     ((vm-image)
      (system-qemu-image os #:disk-image-size image-size))
     ((vm)
@@ -438,10 +441,12 @@ building anything."
                                                 #:full-boot? full-boot?
                                                 #:mappings mappings))
        (grub      (package->derivation grub))
-       (grub.cfg  (operating-system-grub.cfg os
-                                             (if (eq? 'init action)
-                                                 '()
-                                                 (previous-grub-entries))))
+       (grub.cfg  (if (eq? 'container action)
+                      (return #f)
+                      (operating-system-grub.cfg os
+                                                 (if (eq? 'init action)
+                                                     '()
+                                                     (previous-grub-entries)))))
        (drvs   -> (if (and grub? (memq action '(init reconfigure)))
                       (list sys grub grub.cfg)
                       (list sys)))
@@ -524,6 +529,8 @@ Build the operating system declared in FILE according to ACTION.\n"))
   (display (_ "\
    build            build the operating system without installing anything\n"))
   (display (_ "\
+  container         build a Linux container that shares the host's store\n"))
+  (display (_ "\
    vm               build a virtual machine image that shares the host's store\n"))
   (display (_ "\
    vm-image         build a freestanding virtual machine image\n"))
@@ -694,7 +701,7 @@ argument list and OPTS is the option alist."
         (alist-cons 'argument arg result)
         (let ((action (string->symbol arg)))
           (case action
-            ((build vm vm-image disk-image reconfigure init
+            ((build container vm vm-image disk-image reconfigure init
               extension-graph dmd-graph list-generations)
              (alist-cons 'action action result))
             (else (leave (_ "~a: unknown action~%") action))))))
@@ -723,7 +730,7 @@ argument list and OPTS is the option alist."
         (exit 1))
 
       (case action
-        ((build vm vm-image disk-image reconfigure)
+        ((build container vm vm-image disk-image reconfigure)
          (unless (= count 1)
            (fail)))
         ((init)
-- 
2.5.0


  reply	other threads:[~2015-10-27  0:24 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 13:16 [PATCH 01/15] build: syscalls: Add additional mount flags David Thompson
2015-07-06 13:16 ` [PATCH 02/15] build: syscalls: Add unmount flags David Thompson
2015-07-07 14:50   ` Ludovic Courtès
2015-07-07 22:44     ` Thompson, David
2015-07-06 13:16 ` [PATCH 03/15] build: syscalls: Add mkdtemp! David Thompson
2015-07-07 13:15   ` Ludovic Courtès
2015-07-07 22:52     ` Thompson, David
2015-07-06 13:16 ` [PATCH 04/15] utils: Add call-with-temporary-directory David Thompson
2015-07-07 13:15   ` Ludovic Courtès
2015-07-07 22:54     ` Thompson, David
2015-07-06 13:16 ` [PATCH 05/15] build: syscalls: Add clone syscall wrapper David Thompson
2015-07-07 13:23   ` Ludovic Courtès
2015-07-08  0:28     ` Thompson, David
2015-07-11 10:18       ` Ludovic Courtès
2015-07-06 13:16 ` [PATCH 06/15] build: syscalls: Add setns " David Thompson
2015-07-07 13:28   ` Ludovic Courtès
2015-07-08  0:57     ` Thompson, David
2015-07-06 13:16 ` [PATCH 07/15] build: syscalls: Add pivot-root David Thompson
2015-07-07 13:35   ` Ludovic Courtès
2015-07-08  1:18     ` Thompson, David
2015-07-08 12:47       ` Ludovic Courtès
2015-07-06 13:16 ` [PATCH 08/15] gnu: build: Add Linux container module David Thompson
2015-07-07 13:51   ` Ludovic Courtès
2015-07-08 12:38     ` Thompson, David
2015-07-08 21:57       ` Ludovic Courtès
2015-07-09 12:56         ` Thompson, David
2015-07-06 13:16 ` [PATCH 09/15] gnu: system: Move <file-system-mapping> into (gnu system file-systems) David Thompson
2015-07-07 13:51   ` Ludovic Courtès
2015-07-08  1:21     ` Thompson, David
2015-07-06 13:16 ` [PATCH 10/15] gnu: system: Move file-system->spec to " David Thompson
2015-07-07 13:51   ` Ludovic Courtès
2015-07-08  1:22     ` Thompson, David
2015-07-06 13:16 ` [PATCH 11/15] gnu: system: Add Linux container module David Thompson
2015-07-07 13:55   ` Ludovic Courtès
2015-07-09 13:00     ` Thompson, David
2015-07-10 17:57       ` Ludovic Courtès
2015-07-06 13:16 ` [PATCH 12/15] gnu: system: Add Linux container file systems David Thompson
2015-07-07 13:56   ` Ludovic Courtès
2015-07-09 12:56     ` Thompson, David
2015-07-06 13:16 ` [PATCH 13/15] scripts: system: Add 'container' action David Thompson
2015-07-07 14:05   ` Ludovic Courtès
2015-10-27  0:24     ` Thompson, David [this message]
2015-10-27 17:41       ` Ludovic Courtès
2015-10-30 17:28         ` Thompson, David
2015-07-06 13:16 ` [PATCH 14/15] scripts: environment: Add --container option David Thompson
2015-07-07 14:35   ` Ludovic Courtès
2015-07-09 13:16     ` Thompson, David
2015-07-10 18:03       ` Ludovic Courtès
2015-09-05 23:45     ` Thompson, David
2015-09-11 12:39       ` Ludovic Courtès
2015-10-10 21:11         ` Thompson, David
2015-10-11 19:34           ` Ludovic Courtès
2015-10-17 10:05             ` Ludovic Courtès
2015-10-22  1:23               ` Thompson, David
2015-10-25 21:38                 ` Ludovic Courtès
2015-10-26  0:35                   ` Thompson, David
2015-10-27 10:13                     ` Ludovic Courtès
2015-10-31  1:25                       ` Thompson, David
2015-10-31 10:28                         ` Ludovic Courtès
2015-07-06 13:16 ` [PATCH 15/15] scripts: Add 'container' subcommand David Thompson
2015-07-07 14:50   ` Ludovic Courtès
2015-10-27  0:31     ` Thompson, David
2015-10-27 17:46       ` Ludovic Courtès
2015-07-07 13:14 ` [PATCH 01/15] build: syscalls: Add additional mount flags Ludovic Courtès
2015-07-07 22:42   ` Thompson, David

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ=RwfYGvC9Dq9=ntcXstPucL2g3qgqRPB4PyU81jajRj-D6Ww@mail.gmail.com' \
    --to=dthompson2@worcester.edu \
    --cc=davet@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).