boot2docker is a lightweight Linux distribution based on Tiny Core Linux made specifically to run Docker containers. It runs completely from RAM, weighs ~27MB and boots in ~5-6s (YMMV).
Head over to the Releases Page to grab the ISO.
To 'install' the ISO onto an SD card, USB-Stick or even empty hard disk, you can
use dd if=boot2docker.iso of=/dev/sdX.
This will create the small boot partition, and install an MBR.
http://www.youtube.com/watch?v=QzfddDvNVv0
Simply boot from the ISO, and you're done. It runs on VMs and bare-metal machines.
If you want your containers to persist across reboots, attach an ext4 formatted disk with the label boot2docker-data (mkfs.ext4 -L boot2docker-data /dev/sdX5) to your VM, and boot2docker will automount it on /mnt/sdX and then softlink /mnt/sdX/var/lib/docker to /var/lib/docker. It will also persist the SSH keys of the machine.
boot2docker auto logs in, but if you want to SSH into the machine, the credentials are:
login: docker
pass: tcuser
Make sure to setup a port forward from host to guest port 22. Avoid bridged networking due to the static login and password. Or use the boot2docker init script.
boot2docker now comes with a rather simple init script that leverage's VirtualBox's VBoxManage. Essentially, you can init (create), start, suspend, stop delete the boot2docker VM right from the command line.
The VM has the following specs:
- CPU Cores: same as host (physical, not logical)
- 40gb HDD (auto-initialized at first boot)
- 1gb memory
- Autoboots to boot2docker
virtiohigh performance networking- NAT networked (Docker
4243->4243and SSH22->2022are forwarded to the host)
You can customise the values of VM_NAME, DOCKER_PORT, SSH_HOST_PORT, VM_DISK, VM_DISK_SIZE, VM_MEM and BOOT2DOCKER_ISO by setting them in $HOME/.boot2docker/profile
Beware, this is work in progress. To use:
$ mkdir vm
$ cd vm
$ curl https://raw.github.com/steeve/boot2docker/master/boot2docker > boot2docker
$ chmod +x boot2docker
$ ./boot2docker init
$ ./boot2docker up
$ ./boot2docker ssh
docker@localhost's password: tcuser
If ssh complains about the keys:
$ ssh-keygen -R '[localhost]:2022'
If you want to use the brand new Docker OSX client, just tell it to connect to localhost and you should be good to go. boot2docker will automatically detect if it's running in a VirtualBox/QEMU/VMWare and will let dockerd listen on all interfaces:
$ ./boot2docker up
$ export DOCKER_HOST=localhost
$ ./docker version
Get latest Docker OSX client binary release from docker.io:
$ curl -o docker http://get.docker.io/builds/Darwin/x86_64/docker-latest
$ chmod +x ./docker
$ export DOCKER_HOST=localhost
$ ./docker version
$ sudo cp ./docker /usr/local/bin/
or with Homebrew ( http://brew.sh ):
$ brew tap homebrew/binary
$ brew install docker
There's also a Puppet module available, if you want to install with Boxen.
- Kernel 3.12.1 with AUFS
- Docker 0.8.0
- LXC 0.8.0
- Container persistence via disk automount on
/var/lib/docker - SSH keys persistence via disk automount
boot2docker is built with Docker, via Dockerfiles.
It is composed in three distinct steps:
base: fetches, patches with AUFS support and builds the 3.12.1 Linux Kernel with Tiny Core base configurationrootfs: builds the base rootfs for boot2docker (not complete)- running
rootfs: when you run this image, it will build the rootfs, download the latest Docker release and create the.isofile on/of the container. This way you can update Docker without having to completely rebuild everything.
So the build process goes like this:
# $ sudo docker build -t steeve/boot2docker-base base/
# OR for most uses, avoid re-building and downloading lots of ubuntu packages by:
$ sudo docker pull steeve/boot2docker-base
$ sudo docker build -t boot2docker rootfs/
Once that's done, to build a custom boot2docker.iso, just run the built rootfs image:
$ sudo docker rm build-boot2docker
$ sudo docker run --privileged -name build-boot2docker boot2docker
$ sudo docker cp build-boot2docker:/boot2docker.iso .
Now you can install the iso to a USB drive, SD card, CD-Rom or hard-disk. The image contains a Master Boot Record, and a partition table, so can be written to a raw device.
sudo dd if=boot2docker.iso of=/dev/sdX
Login as root
Run sudo -s as the docker user.
Why not CoreOS?
I got asked that question a lot, so I thought I should put it here once and for all. CoreOS is targeted at building infrastructure and distributed systems. I just wanted the fastest way to boot to Docker.
Persistent partition choice
boot2docker will first try to mount a partition labeled boot2docker-data, if that doesn't exist, it will pick the first ext4 partition listed by blkid.
Local Customisation (with persistent partition)
If you have a persistence partition, you can make quick customisations that are run at boot time
in the /var/lib/boot2docker/bootlocal.sh file.
for example, to download pipework, install its pre-requisites (which you can download using tce-load -w package.tcz), and then start a container:
#!/bin/sh
if [ ! -e /var/lib/boot2docker/pipework ]; then
curl -o /var/lib/boot2docker/pipework https://raw.github.com/jpetazzo/pipework/master/pipework
chmod 777 /var/lib/boot2docker/pipework
fi
#need ftp://ftp.nl.netbsd.org/vol/2/metalab/distributions/tinycorelinux/4.x/x86/tcz/bridge-utils.tcz
#and iproute2 (and its friends)
su - docker -c "tce-load -i /var/lib/boot2docker/*.tcz"
#start my management container if its not already there
docker run -d -v /var/run/docker.sock:/var/run/docker.sock $(which docker):$(which docker) -name dom0 svens-dom0
