/
Running Bahmni on Docker (Archived)

Running Bahmni on Docker (Archived)

The following guide helps you in installing Bahmni using Docker. Docker is an open platform for developers and system admins to build, ship, and run distributed applications. Following instructions are mainly targeted for Mac OS X and Linux users. But they should work with any operating system that supports Docker.

Note, this instruction does not work with CentOS 7.x. This is applicable for Bahmni 0.91 on CentoS 6.9+

ARCHIVED PAGE!

This is an ARCHIVED PAGE and available for historial reference only. For LATEST documentation on Bahmni supported docker setup please refer this page instead: Running Bahmni on Docker


Docker installations

You can install Docker community edition from here. Choose the appropriate installers for your host machine and follow the instructions mentioned for the host platform. 

MacOS: You can get the dmg file for Docker here


Once you have Docker installed, ensure that you are running the daemon. If you want to tune and configure docker, please find detailed information here

While it is not mandatory that you have working knowledge of docker (although desirable), at the least you should know the following commands and usages

  1. "docker ps -a"   - shows all containers
  2. "docker rm <container id>" - remove a given container 
  3. "docker container COMMAND" - different commands like start/stop/prune for container(s)
  4. "docker images" - lists all images
  5. "docker rmi <image id>" - remove a given image 
  6. "docker volume COMMAND" - different commands for managing volumes. 


Bahmni Docker Setup Process

Step 1: Create a directory (e.g. dev_dockerFiles) and get the following files and put them in the directory. 

  1. Dockerfile - is a document that contains all the commands to assemble an image, and a way to create an automated build that executes several command-line instructions. 
  2. docker.sh - an utility script to do some basic cleanups and checks and run the docker build and run command. 
  3. db_startup_script.sh - an utility script to setup databases and setup the database configurations and data directories and to restart the services. This also runs every time you start the container. 

Make sure the docker.sh file is executable:

chmod a+x docker.sh


Also, this link has more advanced scripts for cloud hosting, which you will obviously need to enhance for your specific security or SSL certificate installations, but should give you enough pointers on how to use on actual production. 

Dev:Shared Directory from host


If you are spinning up for development purpose, chances are that you want to share files or other artefacts between the host and the container. The simplest way to do this, is to share a directory from the host machine as a volume in the container. To do this, edit the docker.sh file, and modify the last line of "docker run ..."


docker run -e container_name=${container_name} -it -d -p ${https_port}:443 -p ${http_port}:80 -p ${erp_port}:8069 -p ${debug_port}:8000 --privileged --name $container_name -v /<bahmni root directory on your host machine>:/bahmni_host -v $container_name:/$container_name bahmni/bahmni_centos67 /bin/bash

notice the additional volume specified after the "–name $container_name"? Within the container "/bahmni_host" will now be the shared folder with your host machine. 

-v /<bahmni root directory on your host machine>:/bahmni_host



Step 2: In "docker.sh", check and specify version of Bahmni you want to install, what ports to bind and container name that you want to have etc. 

  1. Container name: default container914

    export container_name=container914

    (I like to name the containers by the version of Bahmni I am installing. Notice the name?)

  2. Bahmni Version: change the "rpm_version" variable. 
    export rpm_version=0.91-4

    You can mention a specific version (like above), or the latest (like below)

    export rpm_version=0.91*

    The above is applicable if you are installing the development versions. You will want to have a fixed version for production! The binaries get downloaded from S3 repo, which is mainly used for development/QA purposes, change the repo to bintray in the Dockerfile. 

  3. Ports: These are the ports that will be bound from your host to the docker container. 

    export https_port=443
    export http_port=80
    export erp_port=8069
    export debug_port=8000
  4. Inventory: Specifies what components you want installed. The inventory file controls what components of Bahmni gets installed. For example, if you want PACs (dcm4Chee) to be installed, then you should update the inventory file so that "dcm4chee" and "dcm4chee-db" have the location specified, which in this case would just be 127.0.0.1. In this example, the inventory name is set as "aws_qa03" in the docker.sh file. 

    export inventory_name=aws_qa03

    The inventory file gets downloaded from bahmni-tw-playbooks repo. Note, these are sample inventory files. If you want to have your own inventory file, just download one of the inventory files and modify it appropriately locally, and then specify your local file to be used. To do that follow the steps below (assuming you have your local inventory as "local") 

    a) comment off the below line in "Dockerfile"

    # RUN wget -O /etc/bahmni-installer/local https://raw.githubusercontent.com/Bahmni/bahmni-tw-playbooks/master/inventories/$inventory_name

    b) And add the following line 

    ADD local /etc/bahmni-installer/local


Step 3: Run the following command from the directory you created above ("dev_dockerFiles") 

$ cd dev_dockerFiles
$ sudo ./docker.sh


Step 4: If all goes alright, your docker container is all set, and you can login to the container

$ docker exec -i -t <container_name> /bin/bash


Step 5: Check if Bahmni is running by opening a browser and typing the URL "https://localhost" or "https://localhost/bahmni/home". Also login to the container and see if the servers are running (if you get a message on the browser like 'System down for maintenance').