I am new to docker and I am struggling to have the below scenario working: I have a working webapp image that uses alpine with tomcat 9 as a base image and a added my web app along with a series of user libraries.
Then I have a database image with mysql base, which I imported the database required by my web app to work.
If I run those images separately, they work fine, I have 100% access to them from the host system, no problem at all.
Now, I need them to communicate between themselves, it sounded to me this would be the easy part, but I am failing to make it work.
This is my composer.yml:
version: "3"
networks:
uno:
services:
mysql:
image: mysql
ports:
- "3307:3306"
networks:
- uno
web:
image: unoerp9
ports:
- "8888:8080"
depends_on:
- mysql
links:
- mysql
networks:
- uno
The container starts ok: Check image here
But after some seconds, some erros appear on the log, and the mysql container stops:
mysql_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/bck.sql
mysql_1 | mysql: [Warning] Using a password on the command line interface can be insecure.
mysql_1 | mbind: Operation not permitted
mysql_1 | mbind: Operation not permitted
mysql_1 | ERROR 1822 (HY000) at line 17806: Failed to add the foreign key constraint. Missing index for constraint 'fn_comissao_pagto_grupo_ibfk_1' in the referenced table 'vd_grupo_colaborador'
db_mysql_1 exited with code 1
Since there are erros with the mysql container, the webapp container trigger erros related to not being able to connect to the database, which is completely expected, so I am ommiting those.
Also, as the images work fine separately, I don't think it is some error related to how I built them, it must be something I am missing in my composer file. The expected result is to have both images running and communicating while I am able to access the web image through the browser (localhost:8888/) and the database (localhost:3307).
Any help?