I'm aware that Snappy Ubuntu can host Docker containers. My question is whether it can also be run inside a container, as a Docker guest.
The reason I'm asking is that I can't find any Snappy VM guest containers in the public Docker repository.
Yes, you can: Snappy is just a stripped down version of Ubuntu, and Ubuntu works inside Docker. The fact that Snappy does not appear inside the public Docker repository implies that you have to do things manually.
First, get the latest image:
This file is a QCOW2 image meant for QEMU/KVM, but we can extract its contents for Docker too.
In order to access the files inside a QCOW2 image, you'll need
qemu-nbd, so install it and run:
qemu-nbd -c /dev/nbd0 ubuntu-core-alpha-02_amd64-virt.img
This command will create a "virtual disk" named
/dev/ndb0, with "virtual partitions" named
fdisk -l /dev/nbd0 to get an idea of what partitions are inside the QCOW2 image.
The partition you are interested in is
/dev/ndb0p3, so mount it:
mount /dev/ndb0p3 /somewhere
You are almost done! Just follow Docker's guide on custom base images:
tar -C /somewhere -c . | docker import - snappy
Now you are ready to create your Snappy images on top of that base image. For example, I created a snappy_test image with the xkcd-webserver app installed. Here's the
Dockerfile I used:
FROM snappy:latest RUN snappy install xkcd-webserver EXPOSE 80