Adding a package to boot2docker

January 16th, 2015

Docker is seeing rapid adoption among the software development world. So far it seems to me a very nice way to make software installation much less painful, but there is still plenty of room for improvement.

If you’re running Linux then you can stop reading now. Docker is an abstraction layer over Linux Containers (LXC), they’ve also created a repository where pre-defined containers can be found – you can even add your own. LXC is cool stuff, but it does mean Docker runs Linux.

Windows and OSX users need to use boot2docker, a Tiny Core Linux virtual machine that has just enough stuff to run docker. This is a fine solution but often when people ask about missing tools inside of boot2docker, the answer is to install a container that has the tools you want and run inside of that container. Things quickly start to feel like Inception.

Boot2docker is based on Tiny Core Linux, so you can use the tce-load utility to install additional components if needed. So say we wanted to run Perl:

$ tce-load -wi perl5

You can sniff around the repository to figure out what packages are available.

There is documentation on adding a persistent partition to your boot2docker setup. This is useful if you want to run the tce-load every time you run without having to type it in each time. Getting this setup is a little bit fiddly, and if we’re clever we can do something a bit cooler.

Let’s build a custom boot2docker.iso file! The build process is nicely documented. We can use a Dockerfile to create our own iso with the packages we want.

Before we start, you will want to make sure that your boot2docker is running with enough resources. The default should be 2048MB which should work, you will also need enough disk space on /var/lib/docker/aufs inside boot2docker.  If you have problems consider changing your configuration.

Create a Dockerfile with the following contents:

FROM boot2docker/boot2docker

# Append indicator this is modified image
RUN echo "\nMy modified boot2docker.iso\n" >> $ROOTFS/etc/motd

# Install perl5
RUN curl -L -o /tmp/perl5.tcz $TCL_REPO_BASE/tcz/perl5.tcz && \
unsquashfs -f -d $ROOTFS /tmp/perl5.tcz && \
rm -rf /tmp/perl5.tcz

# build the iso
RUN /make_iso.sh
CMD ["cat", "boot2docker.iso"]

Then follow the boot2docker.iso build process.

$ sudo docker build -t my-boot2docker-img .
$ sudo docker run --rm my-boot2docker-img > boot2docker.iso

The FROM is used to declare the base image we want to start from. We’re building our new container on this base.

The RUN directive is executed against the current image at build time. In this case we can’t use tce-load since we’re not actually running Tiny Core Linux at this point, we’re running against the docker image we are building. This is why we’re doing the installation of perl manually. I based the installation from the boot2docker DockerFile.

The last two steps “build the iso” are lifted directly from the same boot2docker Dockerfile, these are the steps required to actually create the iso file.

Figuring out how to run the boot2docker.iso I’ll leave as an exercise for the reader.

Musings

January 8th, 2015

Wow, 2014 seems to have zoomed by and I only manged to make 3 posts to this blog. There was some (non spam) comment activity from folks who’d found articles I’d written that were useful to them – getting feedback is always nice!

I was quite busy with my work on JavaScript runtimes (specifically Node/V8). You can check out the IBM DeveloperWorks page and grab the product of my team’s efforts. Folks that are keen to see code – should check my GitHub account and you’ll find ports of V8 for PowerPC and s390/zLinux.

Late in the year I switched roles at moved to the team that is delivering container runtimes on the IBM Bluemix cloud. We managed to rush something out the door for DockerCon Europe. It even made the IBM www front page:

Still lots to do in this rapidly evolving space, so it should be an interesting 2015 (which might keep me away from doing side projects).

Despite the fact I didn’t manage to turn out very many posts here, I was tinkering away in my limited spare time. From the top of my head: I fixed an XBox360, did lots of 3D printing (including some 2 color prints); modified my Printrbot to be more reliable; replaced some capacitors in a failing DSL modem to fix it; charged a FitBit using a hacked USB cable.. maybe I’ll try to post up a few of those as I do have notes (each of these posts takes a couple of hours usually).

So there you go, I’ve managed to break the ice and start writing here again. I have some work related stuff that I’ll be posting up here soon and hope to document some of the tinkering projects I’ve done (and have queued up) as well.

Review: Seacans PLA filament

June 19th, 2014

IMG_3021

My printrbot simple shipped with 1lb of black PLA filament. This was great to get started, and it’s amazing how many prints I was able to do with so little plastic. I’ve still got probably 1/2 of the original black left, but I really wanted to do other colors.

I’d seen people coloring their filament using sharpies, and lately it seems that there are some very simple ways to do this with good success. I’ll probably try this next time I want to get some more colors and just buy a 1kg spool of natural PLA.

I had decided I wanted white, clear, and maybe one color (purple?). This sent me down the path of looking at the various places I could order from and trying to justify the shipping costs on top of the $20-$40 price per kg. Worse still, the printrbot store was actually out of stock on all but black when I had the burning desire to buy more filament.

Then I came across seacans.com – really nothing stood out about this vendor over others with the exception that they offered a 2kg rainbow pack for the price of 2kg of filament. Looking at the site today it seems they no longer carry this useful sampler of 8 colors, but they still have very good prices.

There are many options for filament – but my experience with seacans.com was positive. I would use them again.

IMG_3024

The shipment came double boxed. Each spool of filament was bagged in plastic with a desiccant pack. I’ve done quite a bit of printing with the new colors, and in general it’s been successful.

Measuring the thickness of the filament is interesting. The black that shipped with my Printrbot is 1.78mm. The rainbow pack from seacans.com varies across the colors: purple 1.72mm, orange 1.73mm, yellow 1.64mm, green 1.69mm, black 1.76mm, blue 1.69mm, red 1.70mm, and white 1.68mm. It is possible the size varies more across the length of the material. Since the Printrbot filament is not on a spool, I can easily test multiple locations over the entire length and it seems to be pretty consistent at 1.78mm.

With my prints – I haven’t noticed any big variations on the quality of the prints due to the thickness differences. With a 5% size difference you’d think it might show up more in the prints.

Initially I did have some trouble with the extruder gear grinding the filament down and failing to feed. I solved this with a fan (more on that in a future post). I’m not sure this can be simply attributed to the ‘cheap’ filament, but overall heat of the room (summer vs. winter) and feeding from a spool (more drag on the material).

If you can find a ‘rainbow’ pack, it’s worth a 30% premium over single color spools. I’ve had a lot of fun with the 7 new colors (I had black before). I also would suggest that cheap filament, while it may have some quality variation on size – is just fine for the hobby printer folks like myself.