I am trying to containerize my company's app. When I deploy that app in VM, I have to install MySQL in the same VM because the application has a hardcoding 127.0.0.1:3306 in the source code.
Now I am trying to separate the app into 2 containers: app-container and mysql-container.
I have published mysql-container port 3306 to the host machine port 3306:
docker run --name mysql-container -p 3306:3306 -d mysql:latest
The next step is to forward app-container 127.0.0.1:3306 to mysql-container port 3306.
I have tried --network="host" to make the app-container use the host machine's network so I can connect mysql-container's port 3306 from app-container's 127.0.0.1:3306 successfully. However, for some reason, the developer doesn't like it so I have to find another way to achieve that.
I am very new to Docker and container, any help is appreciated!