Running Docker on Crouton Fedora 24

Now that we have VirtualBox in Crouton Fedora, setting up Docker is very easy using Docker Machine. If you don’t know about Docker Machine, it’s a utility to install boot2docker which is a tiny Linux distribution made specifically for running Docker images.

Setting up everything #

First, we want to install Docker (from Fedora repos) and docker-machine:

dnf install docker
curl -L https://github.com/docker/machine/releases/download/v0.7.0/docker-machine-`uname -s`-`uname -m` > /bin/docker-machine
chmod +x /bin/docker-machine

After that, let’s create a VirtualBox Docker VM:

docker-machine create --driver virtualbox default

Sadly this will result in an error somewhat like this:

...
(default) Check network to re-create if needed...
(default) Creating a new host-only adapter produced an error: /bin/VBoxManage hostonlyif create failed:
(default) 0%...
(default) Progress state: NS_ERROR_FAILURE
(default) VBoxManage: error: Failed to create the host-only adapter
(default) VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: VBoxNetAdpCtl: ioctl failed for /dev/vboxnetctl: Invalid argument
...

because ChromeOS kernel doesn’t expose the needed networking capabilities for VirtualBox to make a host-only adapter. If you try to make a bridged adapter, your Chromebook will reboot, so that’s not an option. You have to use NAT, which is still fine, but we have to setup port forwarding, so we can access the VM:

VBoxManage modifyvm "default" --natpf1 "tcp-port2376,tcp,,50001,,2376";

This binds the default boot2docker port 2376 to localhost:50001. You can even setup multiple boot2docker instances and map them all.

Now you can go ahead and start the “default” VM from VirtualBox GUI and wait for it to boot to shell.

Running Docker #

To run Docker from Fedora we have to setup some environment variables first so that Docker knows we are connecting to a “remote” host:

export DOCKER_HOST="tcp://127.0.0.1:50001"
export DOCKER_CERT_PATH=~/.docker/machine/machines/default/
export DOCKER_TLS_VERIFY="1"
export DOCKER_MACHINE_NAME="default"

If you try to run something at this point like:

docker run busybox echo hello world

you should get an error that your certificate is invalid:

Could not read CA certificate "/root/.docker/machine/machines/default/ca.pem": open /root/.docker/machine/machines/default/ca.pem: no such file or directory

Sadly, this is because docker-machine setup failed on us earlier. We can fix it easily by copying certificates from our VM.

Switch to the boot2docker VM and extract the certificates:

mkdir /mnt/host
mount -t vboxsf hosthome /mnt/host
cp /var/lib/boot2docker/tls/*.pem /mnt/host

Screenshot from 2016-06-12 12-47-57.png

By default a VirtualBox shared folder called hosthome is available to us and it is mapped to /home. You can of course add more shared folders from VirtualBox settings.

Afterwards, you can minimize all VirtualBox windows, because we won’t be needing them anymore. Last thing is to move the extracted certs to the correct location:

mv /home/*.pem $DOCKER_CERT_PATH

Now if you try to run something, everything should be fine. For example, I tried .NET Core RC2:

docker run -it microsoft/dotnet:latest

Screenshot from 2016-06-12 12-28-18.png

And that’s how you can run Docker on your Chromebook.

Have fun!

 
7
Kudos
 
7
Kudos

Now read this

Running Fedora 23 Workstation Linux on an Intel BayTrail tablet

In my recent projects I’ve managed to run Fedora (for fun) on pretty much everything including: My phone (see my other post about GNURoot) NVIDIA Optimus laptop Raspberry Pi 2 (armhfp 23 with LXDE works great for me) Azure Virtual... Continue →