Docker installation instruction on Linux Ubuntu

Steps for Installing OpenEMR – Docker on Ubuntu 18.04

sudo apt update
sudo apt upgrade
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce
sudo usermod -aG docker $USER
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
mkdir testopenemr
cd testopenemr
wget https://gist.githubusercontent.com/bradymiller/8f8dc5215b07d287f7dc0fed80bf2b9d/raw/9b2a762849bbf8ce0a0d4dff30c4a359cfa88a44/openemr-502-docker-example-docker-compose.yml
mv openemr-502-docker-example-docker-compose.yml docker-compose.yml
docker-compose up -d
docker logs testopenemr_openemr_1

Then wait 10-15 minutes
then go to http://localhost 5
(you should see the login screen)

1 Like

I did step by step installation couple time, and it’s works without any problems, and I posted tested step by step instruction in this post.
But, it only for test version, not the stable one. Every time we logout from computer, its stops running, and we need to input codes to terminal again, to restart it.
I also need some information how to restore my uploaded data to docker.

Hi @ncavalier ,
I just linked to this thread from the main Docker thread. Recommend starting another thread regarding upgrade, so will then have a nice thread documenting that.
thanks,
-brady

Also, regarding it stopping. It should always run while the computer is on and even restart during a computer shutdown/restart etc. The setting that sets this in the docker-composer.yml that does that is here:
https://gist.github.com/bradymiller/8f8dc5215b07d287f7dc0fed80bf2b9d#file-openemr-502-docker-example-docker-compose-yml-L17

Hi Brady,
Do you have any link to information how to restore my data to docker OpenEMR.

Hi @ncavalier ,

Overall will look something like:

  1. Install 5.0.1
mkdir testopenemr
cd testopenemr
wget https://gist.githubusercontent.com/bradymiller/b629738d5d9aee6c2e8c036e7916c719/raw/1e5b63b3963334a11c7d54e6c466cbf9197ac4ff/openemr-501-docker-example-docker-compose.yml
mv openemr-501-docker-example-docker-compose.yml docker-compose.yml
docker-compose up -d

(NOTE that above is installing OpenEMR 5.0.1!)

  1. Copy files. Will be copying the sites directory from your current install (5.0.1) into the sites directory of the docker.
  2. Copy database. Will dump your current database into a file. Then will truncate (ie. clear it) the database on the docker. Then will import the database from the file into the docker.
  3. Then will edit the docker-compose.yml file and change the 5.0.1 to a 5.0.2.
  4. Then will run docker-compose up -d and viola then magic will happen with 5.0.1 being upgraded to 5.0.2 in several seconds

This gives you a general idea. Step 1 is done from above. Now we need to work on the other steps, which can all be done via command line :slight_smile:

And will get to learn some good commandline skillsets (doing mysqldump and import, copying files into a docker, running commands in the docker without even going into the docker; very fun stuff). First steps are to ensure you have access to your sites directory in your current OpenEMR and what OS your current OpenEMR is in. Just let me know these things.

-brady

2 Likes

Hi Brady, I played around with openemr 502 on docker and removed and installed again it works very good, But when tried to install ver 501 ( the code you provided) returned error result - could you please check if you posted correct address for ver 501. thanks Robert.

Hi @robikny ,

I confirmed above code works for 501. Ensure you aren’t using a port in the docker-compose.yml that is conflicting with a already used port. If still issues, then post the error here.

thanks,
-brady

Thanks Brady it works well.
I tried to put patch 7 on 501 because it has patch 6 - in order to upgrade to 502 all patches should be installed. Could not do it. I think it would be good idea to post along that how to install docker compose to post how to patch database, how to restore and how to upgrade on the docker.

Hi Brady
I did successfully installation of 5.0 1. (6)
Your instruction works perfectly, no any errors.
Next step need more detailed information about restoring tar file.

Tried post below to restore tar. file but got an error after second step

hi @robikny ,

There is documentation for patches and upgrades on docker:
openemr-devops/patch.md at master · openemr/openemr-devops · GitHub
openemr-devops/upgrade.md at master · openemr/openemr-devops · GitHub

-brady

hi @ncavalier ,

Rather than rely on that tar, would actually be best to bypass that and get the files and database directly from the source (the original openemr instance), since the Backup within OpenEMR is not perfect (for example, it can have issues when the database/instance is too large).

-brady

Hi Brady - how to pull correct instance - have problem to process patch update.

Hi Brady,
After spending a lot of time with docker configurations,and I was stuck on data recovery process from my backup.tar to docker. It looks like there is still not actual stable configurations on docker.
I currently finally moved my EMR data from Windows to Linux Mint, and it was very easy and quick re-installation.
I decided for now to stay and run my EMR on Linux platform, and in parallel learn more about docker version.
Thank you Brady for all your support time and recommendations…

2 Likes

Hi @brady.miller,

I’ve been playing around with Docker. OpenEMR v5.0.2 will not install with image mariadb:10.4. Works fine with mariadb:10.2. The errors in the docker log for the openemr instance with 10.4 are as follows:

ERROR IN OPENEMR INSTALL: Unable to execute SQL: SELECT user FROM mysql.user WHERE user = 'openemr' AND host = '%' due to: The user specified as a definer ('mariadb.sys'@'localhost') does not exist

2020-05-16T18:01:22.776547088Z Couldn’t set up. Any of these reasons could be what’s wrong:
2020-05-16T18:01:22.776585736Z - You didn’t spin up a MySQL container or connect your OpenEMR container to a mysql instance
2020-05-16T18:01:22.776592541Z - MySQL is still starting up and wasn’t ready for connection yet
2020-05-16T18:01:22.776597266Z - The Mysql credentials were incorrect
2020-05-16T18:01:24.314500671Z PHP Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘openemr’@‘172.27.0.3’ (using password: YES) in /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php on line 693
2020-05-16T18:01:24.315765641Z ERROR IN OPENEMR INSTALL: Unable to execute SQL: create database openemr character set utf8 collate utf8_general_ci due to: Can’t create database ‘openemr’; database exists

Any ideas?

Venu

Hi @vrjula ,

MariaDB 10.4.13 was just released several days ago and breaks OpenEMR install:
MariaDB 10.4.13 breaks OpenEMR install · Issue #3516 · openemr/openemr · GitHub

There is a fix, which will get into patch 3 (along with rebuild of the packages) in several days.

For now, rec changing the image to mariadb:10.4.12

Ahh, much obliged!

Very cool otherwise…

Venu

Not sure what is causing the issues you’re seeing but this instructional youtube video might help.

You can skip all the virtual box stuff and skip to around the 6 minute mark.

@vrjula , The docker OpenEMR 5.0.2 image has been updated to patch 3, so it will now work with most recent version of mariadb 10.4.