Using an RPI Docker Host
In this blog we look at using a Raspberry PI 2 and a Docker host device. Yes an RPI Docker Host. In the video we use the RPI 2 but I also have it running on a Model B with the single core and 512MB RAM. The Version 2 has 4 cores and 1GB RAM so is better suited to this type or work. But for simple learning the Model B or B+ is fine. I am also running this with just an 8GB SD card or MicroSD card in the model 2. We don’t need a lot of space wither for the host OS or docker containers and images.
Setting the Hostname
This is a little different in the HypriotOS. Their boot loader sets the hostname and we set it in the /boot partition. This means that it can be set before you boot the system if you access the /boot device on another system even Windows. As my system is up and running we can configure this by editing the /boot/occidentalis.txt file and changing the hostname from black-pearl to your hostname. A reboot will then configure the hostname and add entries to the /etc/hosts.
Docker is Pre-Installed
Docker 1.6 is pre-installed on this system so this is an RPI Docker Hosts out of the box. Whilst 1.8 is the latest version 1.6 is not old and better than many current distributions use. The user pi is a member of the docker group so can manage Docker. Any member of the docker group can manage the Docker host. . The password for pi is raspberry and the root password is hypriot.
Show the client version
$ docker -v
Show client server and golang version
$ docker version
Display more detailed information
$ docker info
What is Docker
Docker is a container virtualization product. Allowing quick and easy deployment of services is separated Micro Operating Systems that share the host kernel. The downloaded images are very small and customizable. If you want a web-server or MySQL server you can spin up a container in seconds and the service will be running.
Take a Look
We will now fire up a web-server in its own OS and IP Address. This will be hidden behind a NAT network on the Docker host. To access the web server running in the container we map port 80 on the host to 80 on the container. As we don’t have any images it will download and spin-up with the one command:
$ docker run -d -p 80:80 hypriot/rpi-busybox-httpd
This literally takes a few seconds and then we can browser to the Docker host and see the website. Sure the content is not our own but it easy to add content to the container as it starts.
The video will step you through what we have discussed: