Skip to content

Instantly share code, notes, and snippets.

@kojiromike
Last active August 29, 2015 14:24
Show Gist options
  • Save kojiromike/bc353c64cd4be7552331 to your computer and use it in GitHub Desktop.
Save kojiromike/bc353c64cd4be7552331 to your computer and use it in GitHub Desktop.
Boot2Docker on xhyve

Xhyve Boot2Docker

I got boot2docker running on xhyve. Here's my startup script:

#!/bin/sh

KERNEL=boot2docker/vmlinuz64
INITRD=boot2docker/initrd.img
CMDLINE='earlyprintk=serial console=ttyS0 acpi=off user=docker'

MEM='-m 1G'
NET='-s 2:0,virtio-net'
IMG_CD='-s 3,ahci-cd,boot2docker/boot2docker.iso'
IMG_HDD='-s 4,virtio-blk,boot2docker/hdd.img'
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"

build/xhyve $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD -f kexec,$KERNEL,$INITRD,"$CMDLINE"
  • boot2docker.iso is 1.7.0
  • hdd.img is an empty image I created with dd
  • the kernel and initrd.img I copied from boot2docker running on VirtualBox. (Then, I made sure to kill that instance since VirtualBox + xhyve running together will kill your Mac.)

Once booted, I had to restart the docker daemon with DOCKER_RAMDISK=true. I created this script inside the boot2docker vm:

#!/bin/sh

DOCKER_RAMDISK=true exec /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// -H tcp://0.0.0.0:2376 \
  --tlsverify \
  --tlscacert=/var/lib/boot2docker/tls/ca.pem \
  --tlscert=/var/lib/boot2docker/tls/server.pem \
  --tlskey=/var/lib/boot2docker/tls/serverkey.pem

and then ran chmod +x startdocker && ./startdocker &

Then I was able to run docker run hello-world on the vm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment