Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Our official images are deployed to Docker Hub.

Those images are automatically generated, and all our test environments are using them.

If you are interested in running the reference application with demo data (like https://demo.openmrs.org), check demo repository, as it contains the demo data as well.

Installing Docker and docker-compose

Running Docker locally

See Docker Installation Instructions for your environment.  If running on Linux, check https://docs.docker.com/compose/install/ to install docker compose.

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.

...

an essential tool for containerizing applications, making it easier to distribute and run them in consistent environments. The OpenMRS official images are available on Docker Hub and are automatically generated. These images power our test environments, ensuring consistency across deployments.

  • Reference Application Distribution

  • Platform Distribution

For those interested in a setup similar to the demo site at OpenMRS Demo, the demo repository includes the necessary demo data.

Installing Docker and Docker-Compose

Before running OpenMRS with Docker, you need to install Docker and Docker-Compose:

  1. Running Docker Locally

  2. Running Docker on DigitalOcean

    • DigitalOcean offers a convenient and affordable cloud hosting option for development and testing.

    • Sign up at DigitalOcean if you haven't already.

    • Create a droplet, and choose at least 2 GB of memory for optimal performance.

    • Select Applications > Docker on 14.04 as your droplet image.

    • Once

...

    • your droplet is

...

    • ready,

...

    • SSH into it

...

    • using the provided IP address and

...

    • password

...

Do you have Docker running?

...

    • .

Code Block
languagebash
ssh root@<droplet-ip-address>
  • Verify Docker installation with:

Code Block
languagebash
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.

Option 1 - Deploying OpenMRS within Docker command

...

If Docker isn't installed correctly, revisit the installation steps or search for solutions online.

Deploying OpenMRS with Docker

There are several ways to deploy OpenMRS using Docker:

Option 1 - Direct Docker Command

This is not the recommended

...

The video tutorial referencing the original work done by Chaitya Shah can be seen here (warning: this is mostly not working):

 

Widget Connector
urlhttps://www.youtube.com/watch?v=P8unjqOUicI

Run MySQL Database within Docker

https://hub.docker.com/_/mysql/

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.

...

method. Whenever possible, use Docker-Compose, either manually or through the SDK.

  • Running OpenMRS Interactively

bash
Code Block
languagebash
docker run -it --rm -p 8080:8080 openmrs/openmrs-reference-application-distro:demo
Tip

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.

Code Block

This will run OpenMRS until you terminate the process with Ctrl+C or close the terminal.

  • Running OpenMRS in the Background

Code Block
languagebash
docker run -d --name openmrs -p 80:8080 openmrs/openmrs-reference-application-distro
Tip

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"

This command runs OpenMRS as a background daemon

...

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.

Note

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

Option 2 - Running MySQL and OpenMRS in Docker using the SDK

Check the build-distro command in our SDK.

You can use the SDK to generate the docker-compose files.

 

, freeing up your terminal.

Option 2 - Using the SDK to Run OpenMRS with Docker-Compose

The OpenMRS SDK can generate Docker-Compose files for you. Check the build-distro command for more details.

Option 3 - Running MySQL and OpenMRS

...

Check build-distro on how to generate the docker-compose files (or copy from some of our test OpenMRS instances). 

An example of a working docker-compose fileDirectly with Docker-Compose

If you prefer using Docker-Compose directly, generate the necessary files using the build-distro command, or copy them from existing OpenMRS instances.

Example Docker-Compose File:

Code Block
languageyml
themeEclipse
titledocker-compose.yml
linenumberstrueyaml
version: '2.1'

services:
  openmrs-referenceapplication-mysql:
    restart: "always"
    image: mysql:5.6
    command: "mysqld --character-set-server=utf8 --collation-server=utf8_general_ci"
    environment:
      MYSQL_DATABASE: ${MYSQL_DB:-openmrs}
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-Admin123}
      MYSQL_USER: ${MYSQL_USER:-openmrs}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD:-Admin123}
    healthcheckports:
      test:- "exit 03306:3306"
    volumes:
      - openmrs-referenceapplication-mysql-data:/var/lib/mysql

  openmrs-referenceapplication:
    restart: "always"
    image: openmrs/openmrs-reference-application-distro:demo
    depends_on:
      - openmrs-referenceapplication-mysql
    ports:
      - "8080:8080"
    environment:
      DB_DATABASE: ${MYSQL_DB:-openmrs}
      DB_HOST: openmrs-referenceapplication-mysql
      DB_USERNAME: ${MYSQL_USER:-openmrs}
      DB_PASSWORD: ${MYSQL_PASSWORD:-Admin123}
      DB_CREATE_TABLES: 'true'
      DB_AUTO_UPDATE: 'true'
      MODULE_WEB_ADMIN: 'true'
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/openmrs/"]
      timeout: 20s
    volumes:
      - openmrs-referenceapplication-data:/usr/local/tomcat/.OpenMRS/
      - /usr/local/tomcat/.OpenMRS/modules/ # do not store modules in data
      - /usr/local/tomcat/.OpenMRS/owa/ # do not store owa in data

volumes:
   openmrs-referenceapplication-mysql-data:
   openmrs-referenceapplication-data:

...

Starting Docker Containers

Ensure your docker-compose.yml file on is in the current directory and start the containers:

Code Block
bash
languagebash
# To start database and OpenMRS with default credentials:
$ docker-compose up -d

# 

To

...

override

...

credentials:

Code Block
languagebash
MYSQL_DB=my_database MYSQL_ROOT_PASSWORD=my_root_password MYSQL_USER=my_user MYSQL_PASSWORD=my_password docker-compose up -d

# 

To

...

see

...

logs:

Code Block
languagebash
docker-compose logs -f

# Bring containers down
$ 

To stop and remove containers:

Code Block
languagebash
docker-compose down

# Bring containers down and delete all the data

$ 

To stop, remove containers, and delete all data:

Code Block
languagebash
docker-compose down -v

You Accessing OpenMRS

After the containers are up, you should be able to access OpenMRS in your browser httpat <http://localhost:8080/openmrs/When the installation wizard is finished, you should be redirected to the login screen..> The default credentials are:

  • Username:

...

  • admin

  • Password: Admin123

When If you're running Docker on Linux, it should be trivial to create backups of the docker volumes (there's a folder named 'volumes'  inside your docker folder installation)DigitalOcean, you'll need to use your droplet's IP address.

Backing Up Data

On Linux, backing up Docker volumes is straightforward. Look for the volumes directory within your Docker installation folder.

Customizing MySQL Configuration

If you prefer not to run MySQL in Docker or on the same machine, you can remove the openmrs-referenceapplication-mysql service from the Docker-Compose file and configure the necessary environment variables for OpenMRS as needed.

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

Our official images are deployed to Docker Hub.

Those images are automatically generated, and all our test environments are using them.

If you are interested in running the reference application with demo data (like https://demo.openmrs.org), check demo repository, as it contains the demo data as well.