From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] Creating a docker image with Guix Date: Wed, 04 Jan 2017 22:59:01 +0100 Message-ID: <87d1g2h4gq.fsf@gnu.org> References: <87eg0l85qm.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOtaO-0000ao-7p for guix-devel@gnu.org; Wed, 04 Jan 2017 16:59:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOtaL-0005OO-3d for guix-devel@gnu.org; Wed, 04 Jan 2017 16:59:08 -0500 In-Reply-To: (Ricardo Wurmus's message of "Tue, 3 Jan 2017 16:34:33 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel Howdy! Ricardo Wurmus skribis: > Ludovic Court=C3=A8s writes: > >> I=E2=80=99m not familiar enough with Docker but I=E2=80=99m under the im= pression that we >> should be able to generate an image without even using Docker. :-) > > The attached patch adds a Docker export feature, so you can do this: > > docker load < \ > $(guix archive --export-docker-image=3D$(readlink -f ~/.guix-profil= e)) Woow, that was fast! > Then you can use =E2=80=9Cdocker images=E2=80=9D to show the available im= ages. For some > reason Docker won=E2=80=99t show the name and tag =E2=80=9Cguix archive= =E2=80=9D generates, so > just take the most recently added image. Then run it, e.g. like this: > > docker run --rm -ti d11111472905 /bin/emacs > > This starts the container and runs =E2=80=9C/bin/emacs=E2=80=9D interacti= vely. During > export =E2=80=9Cguix archive=E2=80=9D also links the item=E2=80=99s =E2= =80=9C./bin=E2=80=9D directory to =E2=80=9C/bin=E2=80=9D, > so users can run commands without having to know the long store path. Awesome! > I used it successfully to build an Emacs Docker image like this: > > guix environment --ad-hoc coreutils bash emacs-no-x-toolkit > docker load < $(guix archive --export-docker-image=3D$GUIX_ENVIRONMEN= T) Be sure to let emacs-devel know. ;-) > From d600db91078f28d82324671e3d43acaddc9b9608 Mon Sep 17 00:00:00 2001 > From: Ricardo Wurmus > Date: Tue, 3 Jan 2017 16:20:15 +0100 > Subject: [PATCH] guix: Add Docker image export. > > * guix/docker.scm: New file. > * Makefile.am (MODULES): Register it. > * guix/scripts/archive.scm (show-help, %options, guix-archive): Add > support for "--export-docker-image". > * doc/guix.texi (Invoking guix archive): Document it. Looks great! > --- a/doc/guix.texi > +++ b/doc/guix.texi > @@ -2438,6 +2438,12 @@ Read a list of store file names from the standard = input, one per line, > and write on the standard output the subset of these files missing from > the store. >=20=20 > +@item --export-docker-image=3D@var{directory} > +@cindex docker, export > +Recursively export the specified store directory as a Docker image in > +tar archive format. The generated archive can be loaded by Docker using > +@command{docker load}. Maybe =E2=80=9Cas a Docker image in tar archive format, as specified in @uref{http://=E2=80=A6, version 1.0 of the Foo Bar Spec}.=E2=80=9D I would be in favor of --format=3DFMT, where FMT can be one of =E2=80=9Cnar= =E2=80=9D or =E2=80=9Cdocker=E2=80=9D. Maybe there=E2=80=99ll be others in the future. = WDYT? The paragraph that says =E2=80=9CArchives are stored in the =E2=80=9Cnormal= ized archive=E2=80=9D or =E2=80=9Cnar=E2=80=9D format,=E2=80=9C should be updated. Also, it seems that =E2=80=98-f docker=E2=80=99 would always imply =E2=80= =99-r=E2=80=99, right? That=E2=80=99s reasonable but would be worth mentioning. > +(define (hexencode bv) > + "Return the hexadecimal representation of the bytevector BV." > + (format #f "~{~2,'0x~}" (bytevector->u8-list bv))) Maybe use =E2=80=98bytevector->base16-string=E2=80=99 from (guix utils) ins= tead. > +(define spec-version "1.0") Please add the URL to said spec as a comment. > +;; TODO: heroically copied from guix/script/pull.scm > +(define (temporary-directory) Alternatively, there=E2=80=99s =E2=80=98call-with-temporary-directory=E2=80= =99 in (guix utils). :-) > + (and (zero? (apply system* "tar" "-cf" "layer.tar" > + (cons "../bin" items))) > + (delete-file "../bin")))) This reminds me we should steal this code of Mark=E2=80=99s sometime: https://github.com/spk121/guile100/blob/master/code/tar2.scm Thank you! Ludo=E2=80=99.