ChEMBL Resources

Resources:
ChEMBL
|
SureChEMBL
|
ChEMBL-NTD
|
ChEMBL-Malaria
|
The SARfaris: GPCR, Kinase, ADME
|
UniChem
|
DrugEBIlity
|
ECBD

Thursday, 16 July 2015

myChEMBL + docker










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:
  1. Build
  2. Ship
  3. Run
an arbitrary complex piece of software in a very convenient way.

But why docker and myChEMBL?

 

For myChEMBL in particular, using docker means three things:

  1. 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.
  2. 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.
  3. 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
 
Installation on OS X is much more complicated. This is because the standard OS X installation downloads and configures VirtualBox and runs a very lightweight 64-bit Linux with docker installed. Now the problem is, that it won't work in case of myChEMBL. This is because this Virtual Machine has only 20GB of available disk space and our myChEMBL container is 23GB after decompressing. So in order to use it, you first have to resize the volume, which is explained here: https://docs.docker.com/articles/b2d_volume_resize/. The same instructions apply to Windows.

How to get myChEMBL running on docker?

 

The steps are very simple:
  1. Download the image from the FTP.
  2. Uncompress
  3. Load image into docker
  4. Run it
You may wonder why you have to download the image from ChEMBL FTP website when docker is providing Docker Hub - a place where you can upload and share docker images? Well, this is due to a bug in docker, which prevents some images from pushing. This may be related to the big size of ChEMBL container but there is no easy way to reduce it given that the ChEMBL database itself has a size of 8GB.

So instead of pulling from the Docker Hub we retrieve the images from ChEMBL FTP. This is how it should look like:


  1. 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
  2. Uncompress:
    gunzip mychembl_20_ubuntu_docker.tar.gz
    or:
    gunzip mychembl_20_centos_docker.tar.gz
  3. Load:
    docker load < mychembl_20_ubuntu_docker.tar
    or:

    docker load < mychembl_20_centos_docker.tar
  4. 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:

  1. 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.
  2. 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.
  3. 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.


1 comment:

Gary Wisniewski said...

I noted in your "future work" you're considering using supervisord as a process manager. We were using it for a long time, and you might want to take a look at a process manager designed specifically for Docker: Chaperone Documentation.

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.