10

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.

0

1 Answer 1

10

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.

  1. First, get the latest image:

    wget http://cdimage.ubuntu.com/ubuntu-core/preview/ubuntu-core-alpha-02_amd64-virt.img
    

    This file is a QCOW2 image meant for QEMU/KVM, but we can extract its contents for Docker too.

  2. 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 /dev/ndb0pX. Use fdisk -l /dev/nbd0 to get an idea of what partitions are inside the QCOW2 image.

  3. The partition you are interested in is /dev/ndb0p3, so mount it:

    mount /dev/ndb0p3 /somewhere
    
  4. 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
3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .