Docker on Chromebook

Abiola Ibrahim
5 min readMar 17, 2018

--

It is possible, but do not count on the performance.

Before we continue, you really should not be getting a Chromebook to run Docker containers. That is not what they are made for, at least for now. Also, if your Chromebook is not powered by Intel processor you seriously should invest your time somewhere else.

Despite the subtle warning, if you feel there is no harm in having the option for occasional uses, we are on the same page.

There are multiples ways around this with varying degrees of performance, it comes down to how much you are willing to tinker with your Chromebook. I am only sure of these methods working on Chromebooks with Intel processors, preferably Core m3 and better.

We will cover how to install Docker with and without Developer Mode enabled, as well as some other options.

Without Developer Mode

Surprised? Do not be, as long as your Chromebook has Android support. Thanks to pwdonald for chromeos-qemu-docker.

Most Chromebook users would prefer not to sacrifice the security of Chrome OS and not live with the fear of pressing space bar at boot. You can have Docker without enabling developer mode but this offers the worst performance.

Let us start by installing Termux from Play Store and the remaining instructions are to be done in Termux.

Installing Qemu

Install Qemu dependencies.

pkg install termux-tools proot util-linux net-tools openssh git coreutils wget 

Enable additional termux repo to have access to Qemu package.

wget https://raw.githubusercontent.com/xeffyr/termux-x-repository/master/enablerepo.sh
bash enablerepo.sh

Install Qemu.

pkg install qemu-system 

Preparing the Virtual Machine

Create a directory for this adventure and clone chromeos-qemu-docker in it.

mkdir termux-docker && cd termux-docker
git clone https://github.com/pwdonald/chromeos-qemu-docker

Create a 4GB hard drive for the VM. You can increase the size depending on your available disk space.

qemu-img create -f qcow2 virtual_drive 4G

Download Alpine virtual iso and save the file as alpine_x86_64.iso.

curl -sL http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/x86_64/alpine-virt-3.7.0-x86_64.iso -o alpine_x86_64.iso

Installing Alpine on the Virtual Machine

Start the virtual machine for setup.

bash ./chromeos-qemu-docker/scripts/setup_alpine.sh

After boot, run setup-alpine and follow the prompts. Apart from selecting installation disk drive and keyboard layout, you can go with the default options.

If you encounter internet related errors, use google dns withecho 'nameserver 8.8.8.8' > /etc/resolv.conf and run setup-alpine again.

Once done, exit the virtual machine with Ctrl-A X.

Installing Docker on the Virtual Machine

We are almost there. Now start up the virtual machine.

bash ./chromeos-qemu-docker/scripts/start_persist.sh

Install vim (or nano) to enable the community repository so we can install docker.

apk add --update vim 

Uncomment the community repo from /etc/apk/repositories.

http://alpine.mirror.wearetriple.com/v3.7/main
http://alpine.mirror.wearetriple.com/v3.7/community

Install Docker

apk add --update docker

Start Docker service and congratulate yourself, Docker is now installed.

service docker start

I could not find 32 bit Docker client binaries that can run in Termux, thereby limiting us to invoking Docker from the VM.

Port Forwarding

You need to ensure your container is running on ports 80 or 22 and access them on 100:115.92.2:10080 or 100.115.92.2:10022. You can forward more ports by modifying the -net line in scripts/start_persist.sh.

Developer Mode

You can have Docker with or without Crouton. The process is almost the same as the previous section and you only need to have Qemu installed.

The advantage of developer mode is that you can use Docker client binaries. The performance is also noticeable better (than in Termux) but far from being desirable.

You may also want to check rkt. It gives native performance, can run Docker images and works in Crouton though limited to host network--net=host.

Installing Qemu

Install Qemu with Chromebrew. If you have Crouton, follow the distro’s instructions. e.g. apt-get install qemu in case of Ubuntu.

crew install qemu libjpeg libsdl2

Preparing the Virtual Machine

The process is same as previous section. But in addition, modify scripts/start_persist.sh and scripts/setup_alpine.sh to use qemu-system-x86_64

Installing Alpine and Docker

The process is the same as the previous section.

Using Docker client on host

Modify scripts/start_persist.sh to forward port 2375 by adding ,hostfwd=tcp::2375-:2375 to the -net flag. You can forward other ports this way.

Shut down the VM with Ctrl-A X and start it again with bash ./chromeos-qemu-docker/scripts/start_persist.sh.

In the VM, modify /etc/init.d/docker and insert the following before command. This enables docker daemon to listen on :2375.

DOCKER_OPTS='-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375'

Restart Docker service

service docker restart

We’re done with the VM. Leave it running and get outside the VM in a separate shell session.

Download docker binary.

curl -sLO "https://download.docker.com/linux/static/stable/x86_64/docker-17.12.1-ce.tgz" 
tar xvfz docker-17.12.1-ce.tgz
mv docker/docker /usr/local/bin
chmod +x /usr/local/bin/docker

Try it

docker -H tcp://127.0.0.1:2375 ps

Add DOCKER_HOST=tcp://127.0.0.1:2375 to .bashrc to make it permanent and not having to use the -H flag all the time.

Port Forwarding

Same as previous section. But you access the ports on localhost or127.0.0.1.

Other options

The two other options I know of are to modify ChromeOS kernel or dual boot Linux.

Modifying ChromeOS kernel

This allows you to install VirtualBox and use Docker Machine inside Crouton. I personally have not done this due to the high chance of breaking it whenever there is a ChromeOS update. But if you are brave enough, head over here.

Dual Booting Linux

This is clearly the best option with the best performance. You can use chrx to install Linux and then install Docker as you would on any other Linux pc.

I recommend Ubuntu based GalliumOS due to its support for Chromebooks. Though not all Chromebooks are fully supported.

Conclusion

Docker containers can work on Chromebooks, the experience you get is down to what you choose.

  • Stock ChromeOS preserves the security but gives worst experience.
  • Developer Mode gives better experience than stock but the performance is still very slow compared to native.
  • Modifying the Kernel gives a better experience thanks to Docker Machine. But you risk (soft) bricking your device and breaking VirtualBox after every OS update.
  • Dual Booting gives you native Linux experience but it comes with the baggage of switching from ChromeOS and limited hardware support.

Considering the options, it is safe to say that if your primarily workflow revolves around Docker, Chromebook is not your best option.

You should consider rkt if you simply want to run docker images without requiring Docker workflow e.g. docker-compose.

On a positive note, there are strong indications that virtualization support is coming to Chromebooks soon and that will be a game changer. But until then, these are some ways out for you.

--

--