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.

up vote 8 down vote accepted

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

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.