Boot2Docker on Hyper-V

18Feb14

Boot2Docker is a minimal (27MB) Linux image for running Docker. I started using it yesterday whilst investigating Docker on Mac OS X.

It’s designed to work with VirtualBox, and comes with a script to control the lifecycle of the Boot2Docker VM inside of VirtualBox. There’s no reason however why it shouldn’t be used with other types of virtualisation. As I have a Hyper-V server to hand I thought I’d give it a go on that.

Getting started

I downloaded the latest ISO (v0.54 at the time of writing). Created a new VM with 1GB RAM and a legacy network adaptor [1], and attached the boot2docker.iso file as a DVD drive. This booted up fine, and I could do Docker stuff.

Need persistence

There’s not much point to doing Docker stuff unless you can keep it around. So I needed a persistent disk.

I created a new dynamic VHD called b2d_base.vhd and attached it to the VM on the IDE controller. After starting up again I ran through the following commands:

sudo fdisk /dev/sda
n
e
<enter for default start>
<enter for deafult end>
n
l
<enter for default start>
<enter for deafult end>
w
sudo mkfs.ext4 -L boot2docker-data /dev/sda5

I then shut down the VM, removed b2d_base.vhd and created a new differencing VHD b2d1.vhd based on b2d_base.vhd and attached that to the IDE controller (so if I choose to make more VMs like this I don’t need to bother with the partitioning, formatting and labelling again).

Trying it out

I booted up again and ran:

docker run -d -p 1880:1880 cpswan/node-red-0.5.0t

Once that completed I could then browse to the NodeRed IDE on http://vm_ip:1880 :)

A quick look at my b2d1.vhd showed that it had grown to 914MB – so the persistence on a differencing disk was working.

Note

[1] First time around I used a regular network adaptor, but boot2docker doesn’t have the drivers for that. With a lot more effort I could probably build my own boot2docker with a customised kernel and the right module. For the time being I’ll live with slightly worse network performance.



2 Responses to “Boot2Docker on Hyper-V”

  1. Good job

    Which driver did you use? We left all the network drivers from Linux 3.12.1 in the image, so they should be there. But I recommend you use virtio if you can, for performance reasons :)

    Also, if you can work out the patches needed, we’ll gladly include them.

    • The driver that I’m using for the legacy adaptor is tulip.

      The paravirtualised adaptor needs hv_netvsc (which in turn needs hv_vmbus). At this point it’s probably in for a penny in for a pound, and throw in hv_storvsc, hv_utils and hid_hyperv to get full PV support on Hyper-V.

      It should just be a case of enabling those when configuring the kernel (I’d guess that they’re off by default).

      This post ‘Installing Hyper-V PV Drivers for Linux Guests‘ provides some decent background. The official MS stuff about ‘Linux Integration Services‘ is basically useless (as is their github repo) as it’s all targeted at Enterprise Linux.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

Join 90 other followers

%d bloggers like this: