From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exJp5-0007O5-Nd for guix-patches@gnu.org; Sat, 17 Mar 2018 17:57:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exJp0-0001L2-OX for guix-patches@gnu.org; Sat, 17 Mar 2018 17:57:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:59129) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1exJp0-0001Kd-Ke for guix-patches@gnu.org; Sat, 17 Mar 2018 17:57:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1exJp0-0004OT-8Y for guix-patches@gnu.org; Sat, 17 Mar 2018 17:57:02 -0400 Subject: [bug#30572] [PATCH 6/7] system: Add "guix system docker-image" command. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20180222102933.4978-1-cmmarusich@gmail.com> <20180315040915.5556-1-cmmarusich@gmail.com> <20180315040915.5556-7-cmmarusich@gmail.com> Date: Sat, 17 Mar 2018 22:56:07 +0100 In-Reply-To: <20180315040915.5556-7-cmmarusich@gmail.com> (Chris Marusich's message of "Thu, 15 Mar 2018 05:09:14 +0100") Message-ID: <877eqal62w.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Chris Marusich Cc: bug#30572 <30572@debbugs.gnu.org> Hello Chris, Chris Marusich skribis: > * gnu/system/vm.scm (system-docker-image): New procedure. > * guix/scripts/system.scm (system-derivation-for-action): Add a case for > docker-image, and in that case, call system-docker-image. > (show-help): Document docker-image. > (guix-system): Parse arguments for docker-image. > * doc/guix.texi (Invoking guix system): Document "guix system > docker-image". > * gnu/system/examples/docker-image.tmpl: New file. Neat! > +When using @code{docker-image}, a Docker image is produced. Guix builds > +the image from scratch, not from a pre-existing Docker base image. As a > +result, it contains @emph{exactly} what you define in the operating > +system configuration file. You can then load the image and launch a > +Docker container using commands like the following: > + > +@example > +image_id=3D"$(docker load < guixsd-docker-image.tar.gz)" > +docker run -e GUIX_NEW_SYSTEM=3D/var/guix/profiles/system \\ > + --entrypoint /var/guix/profiles/system/profile/bin/guile \\ > + $image_id /var/guix/profiles/system/boot > +@end example > + > +This command starts a new Docker container from the specified image. It > +will boot the GuixSD system in the usual manner, which means it will > +start any services you have defined in the operating system > +configuration. Depending on what you run in the Docker container, it > +may be necessary to give the container additional permissions. For > +example, if you intend to build software using Guix inside of the Docker > +container, you may need to pass the @option{--privileged} option to > +@code{docker run}. Awesome. > + (define json > + ;; Pick the guile-json package that corresponds to the Guile used to= build > + ;; derivations. > + (if (string-prefix? "2.0" (package-version (default-guile))) > + guile2.0-json > + guile-json)) I think we can use =E2=80=98guile-json=E2=80=99 unconditionally here. > + (mkdir root-directory) > + (initialize root-directory) > + (build-docker-image > + (string-append "/xchg/" #$name) ;; The output file. > + (cons* root-directory > + (call-with-input-file (string-append "/xchg/" #$gr= aph) > + read-reference-graph)) > + #$os-drv > + #:compressor '(#+(file-append gzip "/bin/gzip") "-9n") > + #:creation-time (make-time time-utc 0 1) > + #:transformations `((,root-directory -> ""))))))) Am I right that the whole point of passing several file names to =E2=80=98build-docker-image=E2=80=99 is that here we don=E2=80=99t need to = copy the whole store to =E2=80=98root-directory=E2=80=99, right? I liked the simplicity of accepting a single file name in =E2=80=98build-docker-image=E2=80=99 (no need for #:transformations in that= case), but I reckon that copying everything around just to meet this requirement is inefficient. Otherwise LGTM, thanks! Ludo=E2=80=99.