Creating a Docker Container: Prime95
About a year ago I had a look at Docker and I did not like what I saw. At that time it seemed like perhaps a reasonably good idea but one that would never become reality. Now, however, it appear that they have actually pulled if off and I decided to give it a shot.
The idea behind Docker is to automate the deployment of software by wrapping them in so-called containers that contain everything needed for the execution of the software.
As an initial exercise I will create a Docker container that runs Prime95, an application that search for prime numbers. Prime95 is specifically designed to work with GIMPS, which is a distributed computing project that uses thousands of CPU's to search for prime numbers.
I am administrating a bunch of servers and I have Docker installed on all of them. By having Prime95 wrapped in a Docker container it will be very easy and quick to deploy Prime95 on each server and let it use whatever CPU cycles that are unused.
Well, this is the beauty of Docker. The prerequisites is a working Docker install and nothing else.
Creating the Dockerfile
One of the clever ideas behind Docker is that Docker containers can depend on other Docker containers. In this case I choose to build my container on top of the official Debian container - which is called "debian".
Creating a Docker container begins with creating a file called Dockerfile, so let's create that file and begin with the Debian dependency:
FROM debian:latest RUN apt-get -y update && apt-get install -y curl RUN curl -SL http://www.mersenne.org/ftp_root/gimps/p95v287.linux64.tar.gz | tar -xz mprime && mv mprime /usr/sbin && chmod +x /usr/sbin/mprime COPY runprime / RUN chmod +x ./runprime RUN mkdir prime CMD ["/bin/bash", "-c", "./runprime"]