nextgenhealthcare / connect-docker

Official Dockerfiles for Connect https://hub.docker.com/r/nextgenhealthcare/connect
Mozilla Public License 2.0
78 stars 51 forks source link

MySQL is unavailable. Aborting. #2

Closed rstoermer closed 4 years ago

rstoermer commented 4 years ago

I can't get Connect to run with MySQL (Ran great before without mysql). For some reason the connect container can't connect to mysql, although other containers (like Adminer/ phpmyadmin) can, with the hostname connectdb. With the image 3.8.1 I am getting:

connect_1 | trying to connect to mysql connect_1 | MySQL is unavailable. Aborting.

With the image 3.8.1-zulu-alpine-jdk I am getting:

connect_1 | /entrypoint.sh: line 192: 215 Done echo $dbpassword connect_1 | 216 Segmentation fault | mysql -h "$dbhost" -p -P "$dbport" -u "$dbusername" -e 'SHOW DATABASES' > /dev/null 2>&1 connect_1 | /entrypoint.sh: line 192: 218 Done echo $dbpassword connect_1 | 219 Segmentation fault | mysql -h "$dbhost" -p -P "$dbport" -u "$dbusername" -e 'SHOW DATABASES' > /dev/null 2>&1 connect_1 | MySQL is unavailable. Aborting. smart-or-data-broker_connect_1 exited with code 1

Seems like the information from my env file is not passed into connect? With all other containers in the same docker-compose.yml it works well

However even without the env file, running e.g. "docker run --name connect -p 8443:8443 -e DATABASE='mysql' -e DATABASE_URL='jdbc:mysql://connectdb:3306/mirthdb' nextgenhealthcare/connect:3.8.1-zulu-alpine" produces the same error. I know the password and so on are missing, however the host and port are not found either:

219 Segmentation fault | mysql -h "$dbhost" -p -P "$dbport" -u "$dbusername" -e 'SHOW DATABASES' > /dev/null 2>&1

My docker-compose looks like this:

 connect:
    image: nextgenhealthcare/connect:3.8.1
    ports:
      - 8443:8443/tcp
      - 6554:6554/tcp
    environment:
      - DATABASE=mysql
      - DATABASE_URL=jdbc:mysql://connectdb:3306/mirthdb
      - DATABASE_MAX_CONNECTIONS=20
      - DATABASE_USERNAME=root
      - DATABASE_PASSWORD=${DB_ROOT_PASSWORD}
    volumes:
      - ./connect/appdata:/opt/connect/appdata
  connectdb:
    image: mysql:8
    restart: always
    volumes:
      - ./connectdb/lib/mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=mirthdb
      - MYSQL_USER=${DB_USER}
      - MYSQL_USER_PASSWORD=${DB_USER_PASSWORD}
    ports: 
      - 3306:3306/tcp
jensenak commented 4 years ago

The thing that stands out to me here is the segmentation fault. That implies your container doesn't have enough memory. Perhaps the mysql command can't start because there's not enough memory, and that's what's causing the entrypoint.sh database test to fail?

narupley commented 4 years ago

I don't know whether it's related or not, but I did see that the "mysql-client" package is no longer available on the Debian-based images. I switched it to default-mysql-client so I could rebuild the images, and pushed the 3.8.1 images again to Docker Hub. However it shouldn't affect the Zulu/AdoptOpenJDK images which use Alpine instead. So it doesn't sound like that change will fix your problem here. @jensenak's comment sounds plausible and certainly something to look into.

doggit commented 4 years ago

Could this be due to the default authentication plugin used by MySQL 8.0 (caching_sha2_password)? Try starting MySQL with the --default-authentication-plugin=mysql_native_password. See the MySQL example: https://github.com/nextgenhealthcare/connect-docker/blob/master/examples/mysql-with-volume.yml

cturczynskyj commented 4 years ago

The newest Debian based images now support MySQL 8 auth natively and won't need the --default-authentication-plugin=mysql_native_password, but all other images will as they don't yet have clients that support MySQL 8 auth natively.