Seeking Help Setting up Docker OpenEMR

Situation
Attempting to setup OpenEMR within a Docker Environment

Through Docker I was able to install and get a MySQL Container running.

Following this link, I have pulled openemr and I can run a container with it.

After this point, the link doesn’t provide any further assistance, or at least any assistance that makes sense to me.

There is mention of docker-compose
There is mention that the MySQL needs to be connected with the OpenEMR Container (and that it needs to be connected before the OpenEMR Container can run, but it’s currently running)
I’ve read some forum posts where people have it running, or had trouble configuring OpenEMR to connect with the MySQL, but I have a OpenEMR container running, and the forum post didn’t mention how they got to that point.

I assume that there is some knowledge/experience here that I am missing, but I just don’t know where/how to proceed from this point. I’m at a loss.

OpenEMR Version
6.0.0

Browser:
Mozilla Firefox Developer Edition

Operating System
I’m using: Windows 10 64-bit

Logs
N/A

hi @jj_inno, try these instructions

Hello @stephenwaite

Thank you again for responding to another post of mine.

I have been to that link.

The page mentions:

" You need to run an instance of mysql/mariadb as well and connect it to this container!"

  • I have MySQL setup, and I assume it is referring to the container that the OpenEMR is in, but it doesn’t state how to get to that point

" You can then either use auto-setup with environment variables (see below) or you can manually set up, telling the server where to find the db."

  • I would like to do either of these options (the manual sounds nice so I have a better understanding of how the system and process works and I can explain it to others), but the code block below is just that: a code block, and the block doesn’t specify the name of the file it belongs to, if any, or where to place the block if I needed to create a script or file with it
  • There is also no mention of how to enter any of this in manually; where do I go for that? At what point do I enter all of this is (I assume that will become more evident as the process develops)?

" The easiest way is to use docker-compose . The following docker-compose.yml file is a good example:"

  • Is the .yml referencing the following block of code as the ‘docker-compose.yml’ file? If so, then what was the earlier reference to? Are they the same thing? Is it assumed that using compose that the use of this file will be understood and fall into place?

Again, I assume I am missing something key or important here.

hi @jj_inno, docker is pretty magical so all you need to do is docker-compose up -d from a terminal prompt in the directory you have the .yml file.

Hi Jeb,

All you need to do is copy paste this into a a notepad text file and save it as docker-compose.yml :

# Use admin/pass as user/password credentials to login to openemr (from OE_USER and OE_PASS below)
# MYSQL_HOST and MYSQL_ROOT_PASS are required for openemr
# MYSQL_USER, MYSQL_PASS, OE_USER, MYSQL_PASS are optional for openemr and
#   if not provided, then default to openemr, openemr, admin, and pass respectively.
version: '3.1'
services:
  mysql:
    restart: always
    image: mariadb:10.5
    command: ['mysqld','--character-set-server=utf8mb4']
    volumes:
    - databasevolume:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
  openemr:
    restart: always
    image: openemr/openemr:6.0.0
    ports:
    - 80:80
    - 443:443
    volumes:
    - logvolume01:/var/log
    - sitevolume:/var/www/localhost/htdocs/openemr/sites
    environment:
      MYSQL_HOST: mysql
      MYSQL_ROOT_PASS: root
      MYSQL_USER: openemr
      MYSQL_PASS: openemr
      OE_USER: admin
      OE_PASS: pass
    depends_on:
    - mysql
volumes:
  logvolume01: {}
  sitevolume: {}
  databasevolume: {}

and in terminal open the directory where you saved the file and run docker-compose up wait a few minutes and your Open EMR instance will be running in http://localhost it’s all automated and setup for you with docker.

@stephenwaite @benmarte
Thank you both for the response.

I followed your (@benmarte) directions and was able to get something spun up, and the OpenEMR is now providing me with the issue

“Couldn’t set up”

based on the error

“PHP Fatal error: Uncaught Exception: ERROR: unable to connect to the database as root”

I know I can log into the MySQL that I created, as I have done it.

Regarding the .yml file, I assume some of it is standard and doesn’t need to be changed, but there are some options that I never created (such as the ‘environment’ block, so do they need to be modified?), and /var/lib/mysql doesn’t exist, which makes me wonder if I ever created a database when setting up MySQL.

Is there is default database that is created that I need to point to?

Do I need to change/modify any of the other options within the .yml file?
Is there more that I am missing?

So you don’t need to install anything on your computer besides docker, the docker-compose.yml already has everything setup for you it’s really as simple as just install docker in your terminal/command line cd into the directory where your docker-compose file is and run: docker-compose up

So, currently I have

Docker - I need it
MySQL - Supposedly because it is needed for OpenEMR (stated here )
Portainer - It was suggested for easier Docker/Container management
Docker-Compose - To make the OpenEMR spin up easier, or it’s necessary
OpemEMR - It is spun up, but after CD into the directory where the .yml file is located, and then,

docker-compose up

I receive these errors from the log file:

“Couldn’t set up”

“PHP Fatal error: Uncaught Exception: ERROR: unable to connect to the database as root”

I can start and kill and run and etc the process, but that error is staying consistent when I do.

try doing docker-compose down -v then do docker-compose up again this way it clears our any bad volume data from when you first ran docker-compose up that might be causing the issue

The only things you need installed are docker and docker compose thats it, docker-compose.yml already has an image that includes the OpenEMR files and the maria db already installed and ready to use once it’s running in docker.

What instructions are you following? What OS are you using? Just trying to get a better understanding where the confusion is coming from.

This post is the most instruction I have found to setup OpenEMR in a Docker Container; I have yet to find any others.

The closest thing to instructions that I have found, was at this link.

That link does not provide much in the way of instructions, so I created this post.

I am working in a Proxmox Debian Environment:

Distributor ID: Debian
Description: Debian GNU/Linux 9.13 (stretch)
Release: 9.13
Codename: stretch

Ok, so lets backtrack here if you have never used docker before for anything on your system then I would start by nuking every image/container/volume you can find out how to do so here then proceed with the following.

Copy/paste this to the docker-compose.yml file:

version: '3.1'
services:
  mysql:
    restart: always
    image: mariadb:10.5
    command: ['mysqld','--character-set-server=utf8mb4']
    volumes:
    - databasevolume:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
  openemr:
    restart: always
    image: openemr/openemr:6.0.0
    ports:
    - 80:80
    - 443:443
    volumes:
    - logvolume01:/var/log
    - sitevolume:/var/www/localhost/htdocs/openemr/sites
    environment:
      MYSQL_HOST: mysql
      MYSQL_ROOT_PASS: root
      MYSQL_USER: openemr
      MYSQL_PASS: openemr
      OE_USER: admin
      OE_PASS: pass
    depends_on:
    - mysql
volumes:
  logvolume01: {}
  sitevolume: {}
  databasevolume: {}

In terminal cd to the directory where your docker-compose.yml file is located and run docker-compose up

That will get Open EMR working on your system.

If you want to remove anything else you installed besides docker and docker-compose that would be fine too as that will only cause more confusion, you don’t need anything installed on your system besides docker and docker-compose.

Good luck.

@benmarte

Thank you for the advice and the steps.

I followed through with what you said, and at the moment, this is the output of the logs from OpenEMR when attempting to connect to it via web interface:

PHP Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Try again in /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php on line 1240

PHP Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Try again in /var/www/localhost/htdocs/openemr/library/classes/Installer.class.php on line 1240

PHP Fatal error: Uncaught Exception: ERROR: unable to connect to database as root
in /var/www/localhost/htdocs/openemr/auto_configure.php:43
Stack trace:

}
thrown in /var/localhost/htdocs/openemr/auto_configure.php on line 43
Couldn’t set up. Any of these reasons could be what’s wrong:

  • The Mysql credentials were incorrect,
  • MySQL is still starting up and wasn’t ready for connection yet,
  • You didn’t spin up a MySQL container or connect your OpenEMR container to a mysql instance,
    Couldn’t set up. Any of these reasons could be what’s wrong:,
    thrown in /var/www/localhost/htdocs/openemr/auto_configure.php on line 43,

As long as you didn’t change anything in the docker-compose.yml I don’t see why it would be erroring out.

I would docker pull mariadb:10.5 and docker pull openemr/openemr:6.0.0 just to make sure you got the latest docker images and docker-compose down -v to clear the volumes that could have bad data or whatever files might be causing the issues and then docker-compose up

A good indicator of when to actually try and connect to it via the browser is when you see this in your terminal when you run docker-compose up

openemr_1  | Love OpenEMR? You can now support the project via the open collective:
openemr_1  |  > https://opencollective.com/openemr/donate
openemr_1  |
openemr_1  | Starting cron daemon!
openemr_1  | Starting apache!
openemr_1  | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message

When you see this that means the app is running and ready to be accessed via the browser.

Disclaimer for other users: Using docker-compose down -v will destroy any data you may have in your open emr docker instance so only use this if you’ve never had successfully ran open emr before which is your case.

Good luck.

Here is the end of the log files after running “docker-compose up”

mysql_1 | 2021-03-03 20:08:11+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
mysql_1 |
mysql_1 | 2021-03-03 20:08:11 0 [Note] mysqld (mysqld 10.5.9-MariaDB-1:10.5.9+maria~focal) starting as process 1 …
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Uses event mutexes
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Number of pools: 1
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
mysql_1 | 2021-03-03 20:08:11 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Using Linux native AIO
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Completed initialization of buffer pool
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: 128 rollback segments are active.
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Setting file ‘./ibtmp1’ size to 12 MB. Physically writing the file full; Please wait …
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: File ‘./ibtmp1’ size is now 12 MB.
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: 10.5.9 started; log sequence number 45118; transaction id 20
mysql_1 | 2021-03-03 20:08:11 0 [Note] Plugin ‘FEEDBACK’ is disabled.
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql_1 | 2021-03-03 20:08:11 0 [Note] InnoDB: Buffer pool(s) load completed at 210303 20:08:11
mysql_1 | 2021-03-03 20:08:11 0 [Note] Server socket created on IP: ‘::’.
mysql_1 | 2021-03-03 20:08:11 0 [Warning] ‘proxies_priv’ entry ‘@% root@c97824b434fa’ ignored in --skip-name-resolve mode.
mysql_1 | 2021-03-03 20:08:11 0 [Note] Reading of all Master_info entries succeeded
mysql_1 | 2021-03-03 20:08:11 0 [Note] Added new Master_info ‘’ to hash table
mysql_1 | 2021-03-03 20:08:11 0 [Note] mysqld: ready for connections.
mysql_1 | Version: ‘10.5.9-MariaDB-1:10.5.9+maria~focal’ socket: ‘/run/mysqld/mysqld.sock’ port: 3306 mariadb.org binary distribution

After this point it just sits there, waiting. I can cancel the process, or I can put it in the background, but it doesn’t move past this point.

The following is an exact copy/paste of the docker-compose.yml file:

version: ‘3.1’
services:
mysql:
restart: always
image: mariadb:10.5
command: [‘mysqld’,’–character-set-server=utf8mb4’]
volumes:
- databasevolume:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
openemr:
restart: always
image: openemr/openemr:6.0.0
ports:
- 80:80
- 443:443
volumes:
- logvolume01:/var/log
- sitevolume:/var/www/localhost/htdocs/openemr/sites
environment:
MYSQL_HOST: mysql
MYSQL_ROOT_PASS: root
MYSQL_USER: openemr
MYSQL_PASS: openemr
OE_USER: admin
OE_PASS: pass
depends_on:
- mysql
volumes:
logvolume01: {}
sitevolume: {}
databasevolume: {}

Let it finish it can probably take 5-10 minutes for it to finish setting it up, just be patient and let it run for a few minutes and come back to it later.

I have loaded fully and successfully!

Thank you again for your assistance @benmarte

1 Like

Hello everyone, this post help me to set up Openemr from docker, thank you for all, but i cant share my localhost in other computer under the same wifi network, im using the IP/openemr via in the other computer but doesnt work.
The server have new rules for ports 80 and 443, but this ports listening PID 11504, the process for this PID is com.docker.backend.exe

Can you help me?

This has been a very helpful guide, @benmarte!