In the previous post, I showed how to get Docker 1.12.1 up and running on Raspberry Pi3 in just 5 minutes. Under 1.12.1 release, Docker Inc. provided a FIRST ARM debian package which can be installed using a single curl command. It works great and there has been numerous Ubuntu, Alpine and Debian based ARM Docker images been built and pushed out to Dockerhub. If you are CentOS/Red Hat user, you might be interested in building CentOS based ARM images on top of Raspberry Pi. As of today, there is NO CentOS based Docker image available for ARM architecture under Dockerhub. I had few of X86 based legacy application which only runs on CentOS based system and hence decided to build one of my own for ARM. It is important to note that X86 based Docker image is not going to work on Raspberry Pi box.
This step-by-step guide will help you to build the CentOS 7.2 ARM Docker Image.
Step-1: Download the CentOS 7 specific ARM image from the official CentOS website.
root@raspberry5:/# wget http://mirror.centos.org/altarch/7/isos/armhfp/CentOS-Userland-7-armv7hl-Minimal-1603-RaspberryPi3.img.xz
Luckily, I found that CentOS community has ARM images availability for all popular vendors such as BananaPi, CubieTruck, Pi2 and Pi3. I picked up the right one which will work for my Pi 3 box.
Step-2: Format your microSD card in case you have old Raspbian OS using SD Formatter(Refer here)
Step-3: Use Win32 disk imager to burn it directly into microSD card.
Step-4: Insert microSD card into microSD slot of your Pi 3 box and power it on.
The default username & password is root/centos. This is a minimal CentOS 7 ARM image and hence don’t expect GUI out of this image. By default, WiFi is not enabled. Refer README file under the root directory to get WiFi working. I had a small cable to connect to my router and the network just worked out of the box. I installed vncserver using YUM and could connect to the Pi 3 box without any issue.
Step-5: Ensure that you run “yum update” to get the latest ARM packages for CentOS 7
Step-6: By default, 2GB is the size allocated for / root partition. Follow the below step for expanding it to utilize the full 12GB of the space.
$sudo git clone https://github.com/ctyler/rootfs-resize
$sudo touch /.rootfs-repartition
$sudo systemctl reboot
Step-7:Now configure the YUM repo to pick up the required packages for Docker. I did a little tweaking here by including RPMs available from foreign unofficial repository.
Ensure that you run ‘yum update’ command again to get the latest packages for Docker packages.
Step-8: Run the below command to get the required number of packages to be installed:
$sudo yum install lxc bridge-utils device-mapper device-mapper-libs \
libsqlite3x docker-registry docker-storage-setup docker-io
Ensure that you run the below command to start the docker service:
$sudo systemctl start docker.service
Step-9: Verify if Docker is installed or not on Raspberry Pi 3 through ‘docker version’ utility:
You can get the detailed information about Docker through ‘docker info’ command:
Yipee ! You got Docker installed on your CentOS base image on Raspberry Pi 3 box for the first time.
Let’s quickly try to pull few of the container from Dockerhub.
One can quickly start a container as shown below:
Let’s build up the first Docker ARM image for Dockerhub so that everyone can use it to build application on RPM based ARM container.
Building a container is a simplified process. All you need is a script which you can pull from this github link.Just run the below command to get CentOS 7.2 up and tested automatically:
[root@centos-rpi3 contrib]# sh mkimage-yum.sh -y /etc/yum.repos.d/CentOS-Base.repo centos7
As you see the above command, I have used CentOS-Base.repo as a source repository to create Docker image successfully. Hence, this image is just 210 MB in size. I am planning to shrink it to lower size soon so that it comes up better than before.
Feel free to pull and try out the first CentOS 7.2 container in your Pi box:
$sudo docker run -i -t –rm centos7:7.2 /bin/bash -c ‘echo success’
This is just awesome ! Now I have a platform to build monitoring tool on top of very tiny Raspberry Pi and this is going to be real fun. Will keep you all posted on the latest findings. Till then, keep Reading !