How to get a Baserock build system running in Docker

If you just want a Baserock container in docker, try docker pull baserock/14.29

Docker is a tool that provides containerisation of systems. Baserock produces systems that are suitable for running in containers. It is a match made in heaven!

Running a Baserock build system chroot in a Docker container is an alternative to using the schroot-based baserock-chroot tooling. So far the schroot-based tooling is more widely used than Docker, so you may be less likely to encounter issues with it.

Importing a Baserock chroot tarball as a Docker image

To import a Baserock chroot tarball into Docker as an image, you can do the following:

curl --get $TARBALL | docker import - baserock-build-x86_64:15.25

Replace '15.25' with the current version number of Baserock.

The Baserock build system image should then show up in docker images:

$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
baserock-build-x86_64   15.25               6129ad923746        3 minutes ago       1.294 GB

Running Morph commands in a Docker container

Docker's usual model is that you run a single server process in each container. However, you can start an interactive session using the --interactive and --tty flags:

docker run --name=br --interactive --privileged --tty \
           --volume=$HOME/baserock-src:/src \
           baserock-build-x86_64:14.29 /bin/bash

The --privileged flag is required for two reasons. Firstly, building with Morph requires making bind-mounts, due to the use of linux-user-chroot. Secondly, assembling the fhs-dirs chunk artifacts requires creating device nodes. Both of these are considered privileged operations by Docker and are prevented by default.

Note that we bind-mount in the /src directory as a volume. You should change $HOME/baserock-src in the above example to whatever path you want to use to hold source code and build artifacts). Storing data directly inside a Docker container's filesystem is discouraged. Anything important should be on the host (or a dedicated storage system) instead and should be shared with the container as a volume.

When you exit this shell, the container will be stopped. However, it's not deleted. You can find it in the output of docker ps -a:

$ docker ps -a
CONTAINER ID        IMAGE                         COMMAND             CREATED             STATUS                     PORTS               NAMES
4d00360aaac6        baserock-build-x86_64:14.29   /bin/bash           5 minutes ago       Exited (0) 4 minutes ago                       br

You can continue with it where you left off using docker start --interactive:

docker start --interactive br

Docker things to try

You could tag your image and push it to the docker registry, for example

$ docker tag 6129ad923746 <yourname>/baserock-build-x86_64:14.29
$ docker push <yourname>/baserock-build-x86_64


The Morph test suite fails in Baserock 14.29 inside Docker right now. This seems to be due to use of the following construct in the Yarn tests:

install -m644 -D /dev/stdin << EOF target_file

Docker attaches to the container's /dev/stdin which seems to prevent the above construct from working correctly.

Some Morph operations require Btrfs, such as deploying to rawdisk. You may need to manually modprobe btrfs on the host for this to work.