Monthly Archives: May 2015

A new docker base image for ARM,-running,-using-docker-on-armhf-%28ARMv7%29-devices describes in some detail the build of a docker-optimised Ubuntu for ARM (e.g., r-pi) but it’s broadly similar to the hypriot (Debian) image I have been using which uses overlay rather than aufs.

docker run armv7/armhf-ubuntu_core /bin/echo ‘Hello world’

Anyway, this is the basis for prepping separate mysql and phusion (apache) containers for a Rails application.

Connected to my first running container. Yay!

After building a r-pi MySQL Docker image, I needed to figure out how to connect to it. This turns out to be a simple matter of running the following command,

# docker run -p 33060:3306 --rm -t -i mysql-jur/mysql:5.5.43 bash
root@89594fa99e7e:/# service mysql start
[ ok ] Starting MySQL database server: mysqld . . . . . . ..
[info] Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly..
root@89594fa99e7e:/# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.43-0+deb7u1 (Debian)
mysql> create database test;

And from this point I can create databases in the normal way.

Adding ‘-p 33060:3306’ to the command proxies the database connection to the docker server’s docker0 NIC although the port is only available on IPv6 and the iptables rules are for a different address to that of the NIC. More to investigate.

Next on the list is getting the database created automatically in the container so that we can reference it from a WordPress image. Pleased that I’m making progress.


My first running container

After discovering that I can’t use the default mysql docker image because MySQL doesn’t support a binary distribution on ARM, I figured that I’d have to create my own.

This should be a simple matter a preparing a Dockerfile,

FROM resin/rpi-raspbian:wheezy
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
#RUN groupadd -r mysql && useradd -r -g mysql mysql
# FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db:
# File::Basename
# File::Copy
# Sys::Hostname
# Data::Dumper
RUN apt-get update && apt-get install -y perl --no-install-recommends && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y libaio1 && rm -rf /var/lib/apt/lists/*
# gpg: key 5072E1F5: public key "MySQL Release Engineering <>" imported
RUN gpg --keyserver --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
# Attempt to install the mysql packages; no tarball for r-pi (arm) exists publicly
RUN apt-get update \
 && apt-get install -y mysql-server-5.5 --fix-missing \
 && rm -rf /var/lib/apt/lists/*\
 && { \
 echo '[mysqld]'; \
 echo 'user = mysql'; \
 echo 'datadir = /var/lib/mysql'; \
 } > /etc/mysql/conf.d/docker.cnf
VOLUME /var/lib/mysql
CMD ["mysqld"]

And then running the following to create the image,

# docker build -t mysql-jur/mysql:5.4.43 .

This generates a lot of output but finishes by confirming the image is built.

We then run the image with,

# docker run -p 33060:3306 -t mysql-jur/mysql:5.5.43

And now what I need to do is figure out how I connect to the container database.

Again lots of output from MySQL setting up InnoDB, etc.

First experiments with Docker

To try and ease the rapid deployment of WordPress sites I am thinking of using Docker images for MySQL and WordPress along with a deployment tool to pull customisations from Github.

I’ve got a few Raspberry PIs lying around at home and a wee bit of spare time to investigate this kind of setup.

First off, Find a Linux image to burn to the SD card. The links below include a couple but 1GB isn’t enough space to install additional packages.

Be warned, however, that I’m trying to prepare the SD cards on a Mac and I’m not sure it’s going to be much for resizing the Linux disk partition.

Download the Debian image and burn it to a 16GB SD card,

# sudo -s
# dd if=Downloads/hypriot-rpi-20150301-140537.img of=/dev/disk1 bs=1m

Then we need to expand the root filesystem with – I will complete this a bit later as it can’t be done on a Mac (see resources). This happens automatically when the PI is first booted.

Then boot the PI and I would advise setting a static IP address so that we don’t need the HDMI output and allow remote SSH. Reboot.

Then SSH to the PI from your workstation and grab the dockerfiles for MySQL and WordPress.

# docker run --name WordPress -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.5

The repeat for WordPress,

# docker run --name wordpress --link some-mysql:mysql -p 8080:80 -d wordpress

Okay, so the above commands are exactly correct but you get the gist and this is really a reminder of the links I need to get back to this later on. (Probably should be tracking this via an Asana task).