Docker

Docker is 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.

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

docker -v

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 method. Whenever possible, use Docker-Compose, either manually or through the SDK.

  • Running OpenMRS Interactively

docker run -it --rm -p 8080:8080 openmrs/openmrs-reference-application-distro:demo

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

  • Running OpenMRS in the Background

This command runs OpenMRS as a background daemon, 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 Directly 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:

Starting Docker Containers

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

To override credentials:

To see logs:

To stop and remove containers:

To stop, remove containers, and delete all data:

Accessing OpenMRS

After the containers are up, you should be able to access OpenMRS in your browser at <http://localhost:8080/openmrs/.> The default credentials are:

  • Username: admin

  • Password: Admin123

If you're running Docker on 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.

Related pages