[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating a docker image with Guix

From: Ricardo Wurmus
Subject: Creating a docker image with Guix
Date: Mon, 2 Jan 2017 13:54:30 +0100
User-agent: mu4e 0.9.16; emacs 25.1.1

Hi Guix,

I just played around with Docker and built up a command to create a
Docker image for Emacs.

Can anyone find a more elegant way to do this?

--8<---------------cut here---------------start------------->8---
guix environment --ad-hoc \
    coreutils bash emacs-no-x-toolkit -- \
    sh -c 'tar -c $(guix gc --requisites $GUIX_ENVIRONMENT) | \
           docker import -c "ONBUILD RUN [\"$GUIX_ENVIRONMENT/bin/ln\", \"-s\", 
\"$GUIX_ENVIRONMENT/bin\", \"/bin\"]" - emacs-base' \
           && echo -e "FROM emacs-base\nCMD [\"/bin/emacs\"]" | \
           docker build -
--8<---------------cut here---------------end--------------->8---

What happens here is this:

* using “guix environment” build a temporary profile containing
  coreutils (for “ln”), bash (for “sh”), and emacs

* inside the environment $GUIX_ENVIRONMENT points to the profile; take
  all of the requisites for this profile (“guix gc --requisites”) and
  send them to “docker import” using a tar pipe

* modify the base image such that it links the profile’s “bin” directory
  to “/bin” when a derivative image is built

* name that base image “emacs-base”

* then build a derivative of this base image with “docker build” (this
  causes “ln -s” to be executed) and make it run the command
  “/bin/emacs” by default

The result is an unnamed image (“docker build” reports an image id such
as “ae8d6281b56f”) that can be run interactively like this:

    docker run -it --rm ae8d6281b56f

What do you think?  Gross?

~~ Ricardo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]