Docker Installation

Page Sections

Option 1

Thanks to Eric Rasche of Texas A&M / CPT and Anthony Bretaudeau of INRA, a docker image for a base Tripal site is now available. The Docker image is located on GitHub at this location: https://github.com/erasche/docker-tripal

Installation of the Docker image will allow for quick setup of Tripal with considerable time saving. Their docker application consists of three containers: one for Drupal and Tripal, another for PostgreSQL (in which Tripal stores data) and an optional container for ElasticSearch for fast indexing and querying of data in Tripal. The following instructions will setup the container with default settings.

Install Prerequisites

Before proceeding both Docker and Docker-compose must be installed. Installation instructions for each tool can be found at the following links:

Install the Tripal Application

Once Docker and Docker-compose are installed you must create a docker-compose.yml file describing how to launch the Tripal Docker application. A ready to use example is available from https://github.com/erasche/docker-tripal. Navigate to an empty working directory and issue the following command:

wget https://raw.githubusercontent.com/erasche/docker-tripal/master/docker-compose.yml

This will install the most recent development version of the example docker-compose.yml file. Currently there is not a stable release for Tripal v2.1 so we'll use the development branch. However this may mean that at any given point in time, until the stable version is released this instructions may not work. Please report a problem if you encounter one.

Once the file is downloaded, you are ready to launch the docker containers. Do so by entering the directory and issuing the docker-compose command:

sudo docker-compose up

This process will take up to several minutes to complete. Once finished you should then be able to view your Tripal site at this URL:  http://localhost:3000/tripal.  Keep in mind that any URLs in the remainder of the tutorial may be listed simply as http://localhost.  Because we have installed the Docker image we must mentally substitute the http://localhost:3000/tripal URL.

Command-line Access

Throughout this tutorial there are times when access to the command-line is desired.

The easiest method is to run the following command from the working directory:

sudo docker-compose exec -it web bash

Similarly, you can get command-line access to the two other containers by running one of these 2 commands:

sudo docker-compose exec -it db bash
sudo docker-compose exec -it elasticsearch bash

Another option exists to obtain access to the container containing the Tripal site: we must first find the container name. The following command will list all of the active containers:

sudo docker ps

Output similar to the following will be printed to the screen:

CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                  NAMES
b1764039943f        erasche/tripal:latest                "/usr/local/bin/ti..."   6 minutes ago       Up 6 minutes        0.0.0.0:3000->80/tcp   dockertripal_web_1
36718e982c8c        erasche/chado:1.31-jenkins97-pg9.5   "/docker-entrypoin..."   6 minutes ago       Up 6 minutes        5432/tcp               dockertripal_db_1
c28145021680        elasticsearch                        "/docker-entrypoin..."   6 minutes ago       Up 6 minutes        9200/tcp, 9300/tcp     dockertripal_elasticsearch_1
 
In the output above the three containers (one containing Tripal, one containing PostgreSQL (i.e. with Chado), and one for ElasticSearch) that are running.  The name of the container containing Tripal is named dockertripal_web_1.  Now that we know the name we can gain access to the command-line with the following command:
 
sudo docker exec -it dockertripal_web_1 /bin/bash

You can connect to any of the three Docker containers by changing the name in the command.

Advanced configuration of the containers

To run a Tripal instance in production, you will probably want to modifiy the configuration of the 3 containers. To do this, you just need to open the docker-compose.yml file and adapt it to your needs.

The exact syntax of this file is describe in the Docker-compose documentation. A description of the things you can configure in the Tripal container is available on https://github.com/erasche/docker-tripal.

 

Option 2

The Staton lab also created a docker image for quickly setting up a Tripal environment for testing and development purposes. This docker image should NOT be used to run Tripal instances in production. This docker image wraps all components into one container and does not need docker-compose.

Launch a Tripal v2 site and access the container

Run the following command line on a terminal.

docker run -it -p 8080:80 mingchen0919/docker-tripal-v2 /bin/bash

The site will be available at http://127.0.0.1:8080/ with user name admin and password admin.

Mount host directory to the container

You can mount a host directory to the container. The mounted host directory will be mapped to a container directory you have specified. Then you can open files within the mounted host directory with your favorite IDE and start your developing work. All file updates will be immediately reflected in the container.

For example, you can create a custom folder on your desktop (/Users/Desktop/custom, the path may be different, depends on your OS) and map this to the container directory /var/www/html/sites/all/modules/custom by running the following command:

docker run -it -p 8080:80 \
  -v  /Users/Desktop/custom:/var/www/html/sites/all/modules/custom \
  mingchen0919/docker-tripal-v2 /bin/bash

If you put your custom module mymodule in the host directory /Users/Desktop/custom, the module will be mapped to /var/www/html/sites/all/modules/custom/mymodule. You can enable/disable the module as usual.

Use drush

The docker image also has Drush installed. To use drush, you will need to get into the container.

To get a container ID
docker ps -a
To start a stopped container
docker start your_container_id
To attach to a running container
docker attach your_container_id

After you get into the container, you can use Drush. The following code shows how to install the Tripal Analysis Expression module and enable it with Drush.

cd /var/www/html/sites/all/modules/custom
git clone https://github.com/tripal/tripal_analysis_expression.git
drush en tripal_analysis_expression -y

Launch a Tripal V3 site and access the contaienr

A docker image for Tripal v3 is also available. Operations are similar to Tripal v2. You just need to replace docker-tripal-v2 with docker-tripal-v3 in previous steps.

docker run -it -p 8080:80 mingchen0919/docker-tripal-v3 /bin/bash

More details can be found at github repository https://github.com/tripal/docker-tripal-centos.