Page tree
Skip to end of metadata
Go to start of metadata

Docker is a unique container/image based platform made to let people distribute applications easily.

The image we are going to be deploying is located on Docker Hub with the source on GitHub.

The video tutorial referencing the original work done by Chaitya Shah can be seen here:

 

Installing Docker

Running Docker locally

See Docker Installation Instructions for your environment.  

Running Docker on Digital Ocean

Digital Ocean provides low case and convenient cloud hosting for development and testing.  There may be cheaper alternatives for permanently hosting a website, but Digital Ocean is one of the fastest ways to get a temporary server up and running.

  1. Create an account (free) if needed, then sign into digitalocean.com.
  2. Create a droplet (takes 1 minute or less)
    1. Name: "openmrs" (or whatever you like)
    2. Size: at least 2 GB of memory (choosing the default environment or any one with less than 2 GB of memory may fail to run OpenMRS)
    3. Image: select Applications > Docker on 14.04
  3. Once the droplet is created, log into it:
    1. View the droplet info to get its IP address and SSH into it – e.g., ssh root@xxx.xxx.xxx.xxx – using the password for the droplet you received via email.
    2. Access the droplet's terminal directly through the Digital Ocean website, by selecting your droplet and selecting Access > Console Access, using the password for the droplet you received via email.

Deploying OpenMRS within Docker

Do you have Docker running?

docker -v

Docker should report its version number, which should be 1.5.0 or higher.  If you get an error message, then you haven't gotten Docker installed properly; go back through the installation process and/or Google for solutions.

Run OpenMRS within Docker

Running interactively

In this mode, OpenMRS will be running until you cancel (e.g., using Ctrl+C) or close your terminal.

docker run -it --rm -p 80:8080 burke/openmrs-core-docker

If you are running docker directly on a linux host or, for any other reason, don't want to use the default web port, you can change the port for OpenMRS by changing the -p 80:8080 parameter. For example, to run OpenMRS on port 8888, use the parameter -p 8888:8080.

Once you see

INFO: Server startup in --------- ms

OpenMRS should be up and running.

Running in background

In this mode, OpenMRS will run in the background and continue running – even if you exit your terminal – until you stop it.

docker run -d --name openmrs -p 80:8080 burke/openmrs-core-docker

If you are running docker directly on a linux host or, for any other reason, don't want to use the default web port, you can change the port for OpenMRS by changing the -p 80:8080 parameter. For example, to run OpenMRS on port 8888, use the parameter -p 8888:8080.

The above command will run a docker container with the name "openmrs" as a background daemon (-d), mapping it to the default web port (80), and will return you to a command line.  The console output for OpenMRS will be logged into that containers log.

To view the tail of the background container's log:

docker logs openmrs

To follow the background container's log file (quit watching by pressing Ctrl+C):

docker logs -f openmrs

To delete the OpenMRS container (e.g., if you want to start over with a new container):

docker rm -f openmrs

Browse to OpenMRS

The location of OpenMRS will depend on how you ran it and which environment you are using for Docker.

Once you've found your OpenMRS installation, you should see the installation wizard and can follow the steps of the wizard to complete the installation.

When the installation wizard asks for the root password for the database, enter the password: test

When the installation wizard is finished, you should be redirected to the login screen.

Username: admin
Password: Admin123 

Developing OpenMRS Core using Docker

You can install OpenMRS Core using Docker and setup your development environment with just one command. Visit OpenMRS-Docker to get started!

 

5 Comments

  1. Burke Mamlin - I've been trying to run OpenMRS in the background but somehow never get to the stage where OpenMRS is installed on the droplet.

    It seems as if it's managing to pull in the repository but not installing it

    Error Logs:

    root@xxxxxxopenmrs:~# docker logs openmrs

    Starting MySQL database server: mysqld ..

    Checking for tables which need an upgrade, are corrupt or were 

    not closed cleanly..

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    /root/run.sh: line 7: /etc/init.d/tomcat7: No such file or directory

    tail: cannot open `/var/log/tomcat7/catalina.out' for reading: No such file or directory

    1. There was a typo in the Dockerfile.  I fixed it and it should work better for you now.  You'll want to remove any container & image before trying again.

      Remove (-f to force, even if it's running) any container named openmrs:

      docker rm -f openmrs

      Remove the image:

      docker rmi burke/openmrs-core-docker

      Then you can try running in the background again.

      1. Thank you, Burke. I just tried and received the very same error. Running on EC2 Amazon Linux instance.

  2. What if root has password, is it gonna  the same command?

    docker run -it --rm -p 80:8080 burke/openmrs-core-docker

    1. Currently, the openmrs-core-docker build includes MySQL, sets the database user=root and password=test in the build, and is not designed to take any parameters for using different credentials. When we get a chance to improve it, a better approach (following Docker's best practice of one app per container) would be to take MySQL out of this container and, instead, expect a MySQL container to be linked & credentials passed in the environment via parameters.