In addition to the myChEMBL 20 VM images released earlier, today we are very happy to release myChEMBL Docker images.
What's docker?
Docker is a new open-source project that automates the deployment of distributed applications. It takes advantage of some new cool features of modern Linux kernel in order to run virtual containers, avoiding the overhead of starting and maintaining virtual machines [from Wikipedia].
In contrast to virtual machines, which emulate virtual hardware, docker containers employ the kernel of the host machine so they don't require or include the whole operating system. While still separated from the host, they only add a very thin level of abstraction [ZDNet article].
Why docker?
Docker is an emerging technology; it has become extremely popular over the last year and been adopted and used by the largest IT companies, such as RedHat, Canonical and Microsoft. Basically, using this platform you can do three things:
- Build
- Ship
- Run
But why docker and myChEMBL?
For myChEMBL in particular, using docker means three things:
- Less data to download so less time to wait. VM-based Ubuntu and Centos images available from our FTP have 8.5 and 6.5 GB of size respectively (after compression). Compressed myChEMBL docker containers are both about 5.7 GB.
- No waiting to boot up. Normally, when you attach a disk image containing myChEMBL to your virtual machine or use vagrant to do it for you, you still have to wait a few minutes for the machine to start. With docker containers there is no booting so everything runs immediately.
- This is a future plan - layers. The whole concept of docker images is based on the fact, that they are build on top of other containers. Since this is our first release of myChEMBL which supports docker, we put everything into a single layer that is build on top of Ubuntu or CentOS, depending on the flavour you choose. However, in future we plan to divide our software into several layers so you can mix and match layers, for example download an image containing database without webservices or webservices layer but no interface and so on.
How do I install docker?
This is the tricky part. The easiest way is to have a clean 64-bit Linux machine (yes, a physical machine) with modern Linux kernel, such as Ubuntu (versions 14.04, 12.04 and 13.10 are officially supported). Many other Linux distributions can work as well, but the most important thing is that the minimal version of the Linux kernel is 3.10 and it has to be a 64-bit machine. In Ubuntu case, all you have to do is to run:
wget -qO- https://get.docker.com/ | sh
How to get myChEMBL running on docker?
The steps are very simple:
- Download the image from the FTP.
- Uncompress
- Load image into docker
- Run it
So instead of pulling from the Docker Hub we retrieve the images from ChEMBL FTP. This is how it should look like:
- Download:
wget http://ftp.ebi.ac.uk/pub/databases/chembl/VM/Docker/mychembl_20_ubuntu_docker.tar.gz
or:
wget http://ftp.ebi.ac.uk/pub/databases/chembl/VM/Docker/mychembl_20_centos_docker.tar.gz
- Uncompress:
gunzip mychembl_20_ubuntu_docker.tar.gz
or:
gunzip mychembl_20_centos_docker.tar.gz - Load:
docker load < mychembl_20_ubuntu_docker.tar
or:
docker load < mychembl_20_centos_docker.tar - Run:
docker run -p 2222:22 -p 80:80 -p 9612:9612 -t -i chembl/mychembl_20_ubuntu /usr/local/bin/supervisord
or:
docker run -p 2222:22 -p 80:80 -p 9612:9612 -t -i chembl/mychembl_20_centos /usr/bin/supervisord
After successful completion of the steps above, you can open you browser and go to http://127.0.0.1/ if you are running docker locally or http://some_other_host/ if you are running docker on some other host. You should then be able to see myChEMBL launchpad page.
As you can see we expose three ports: 80 for myChEMBL launchad web page, 9612 for IPython notebook server and 22 (which is mapped to 2222 in our example) for ssh. This means that you can easily ssh into the container by executing:
ssh chembl@some_other_host -p 2222
The password is always chemblvm. As you see we've decided to remap the standard ssh 22 port into 22 because it can happen, that your machine is running sshd as well in which case there could be a clash. The same applies to ipython notebook, we've chosen 9612 port avoid clash if you are running Ipyhton on your machine already. The only exception here is port 80, which we kept as it is, so if you have some other server running on this port you have to remap as well, for example:
docker run -p 2222:22 -p 8080:80 -p 9612:9612 -t -i chembl/mychembl_20_ubuntu /usr/local/bin/supervisord
If you would like to expose postgres as well, then enabling standard postgres 5432 port is required:
docker run -p 5432:5432 -p 2222:22 -p 80:80 -p 9612:9612 -t -i chembl/mychembl_20_ubuntu /usr/local/bin/supervisord
Future work
Working on docker support for myCHEMBL was great fun and an important lesson of DevOps. There are a number of things we would like to improve in future in myChEMBL itself and the docker related parts to make it even better:
- Use supervisor as a default process manager for myChEMBL.
Docker is designed to run one (typically foreground) process per container. Moreover, Docker ignores initialization of OS-specific daemons such as upstart, systemd etc. This is where supervisor comes handy and it can be used as a default process manager instead of any OS-specific mechanisms even if docker is not used. Same as `pip` tool is better for installing python packages, instead of using 'apt-get' or 'yum', in the similar way using supervisor for managing python web applications is better than systemd or upstart.
- Provide a Dockerfile.
Dockerfile is like a recipe, describing all steps, dependencies and settings necessary to repetitively build and use docker image. Having a dockerfile (or a set of dockerfiles) for myChEMBL would make a process of preparing a container more transparent and robust. We already have a script called bootstrap.sh used to build our VM images but because of subtle differences between docker containers and VMs (look point 1) it can't just be used as is.
- Implement layers.
As mentioned above, having defined some logical components of myChEMBL and distributing them into separate layers would encourage combining different aspects of the system, leading to less time spent on downloading and installing the whole thing.
Comments
Disclaimer: We built this ourselves and open-sourced it, but it really has solved boaloads of problems for us and a few of our clients. Always very very interested in feedback.