Docker Compose Lucee & MySQL

Hi,
I am using Docker Compose for a Lucee app. Docker is loading Lucee and Mysql ok. I can use Adminer to access the database, I can go to Lucee Admin.
But when I try to create the datasouce, it does not connect with MySQL Server.

Here is the docker-compose.yml file:

version: β€œ3”

services:
parentedb:
container_name: parente_db
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: parente
volumes:
- β€œ./db-data:/var/lib/mysql”
ports:
- 3306:3306
adminer:
container_name: parente_adminer
image: adminer
restart: always
ports:
- 8080:8080
cfml:
container_name: parente_cfml
image: lucee/lucee
environment:
MYSQL_HOST: parentedb
MYSQL_DATABASE: parente
volumes:
- β€œ./www:/var/www”
- β€œ./password.txt:/opt/lucee/server/lucee-server/context/password.txt”
ports:
- 4040:8888

Can someone help me ?
Thanks

Don’t forget to tell us about your stack!

OS: Mojave
Java Version: 1.8.0_121
Tomcat Version: 7.0
Lucee Version: Latest

@rparente based on the information you provided I think your question is more about docker than it is lucee. I believe what you need to do is add networking to your configuration so that your cfml service will have access to your parentedb service. You can read about how to add that here: https://docs.docker.com/compose/networking/

These are the steps to take define your networks:

networks:
    backend:
        driver: bridge

And then in your services that need to access eachother:

cfml:
      networks:
            - backend
parentedb:
      networks:
            - backend

If you do that as long as your host and port information are correct lucee should have access to your datasource.

Hope this is helpful!

1 Like

Thank you Jasperboyd !
It really helped.
I also discovered that the OS was running on start its MySQL using the same port 3306. I stopped that instance and applied also your fix and everything is working now.
Thank you so much !

1 Like