So I am running a few Docker containers on a host that has MySQL already running on it. I would like to also run MySQL in a Docker container on that same machine. I set up my Docker compose file to use 3307 instead but when my application tries to get a DB connection I see:
web_1 | Could not connect ... 2003: Can't connect to MySQL server on 'db:3307' (111 Connection refused)
web_1 | 10.0.2.2 - - [04/Mar/2019 21:06:31] "GET / HTTP/1.1" 500 -
I have tried all sorts of different network configurations but each one creates a new issue. Here is the compose file I am docker-compose.yml file using and the output of 'docker container ps'
[jim@localhost ~]$ docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0f12368ee8d jimpython_web "python ./app.py" 4 minutes ago Up 4 minutes 0.0.0.0:5000->5000/tcp jimpython_web_1
9b0efbf08069 jimpython_celery "celery worker -A ..." 4 minutes ago Up 4 minutes jimpython_celery_1
fcc72e5a9fdd mysql:5.7 "docker-entrypoint..." 15 minutes ago Up 4 minutes 33060/tcp, 0.0.0.0:3307->3306/tcp jimpython_db_1
0b65a78a56f2 redis:alpine "docker-entrypoint..." 15 minutes ago Up 4 minutes 0.0.0.0:6379->6379/tcp jimpython_redis_1
3c2d1551c165 mongo "docker-entrypoint..." 15 minutes ago Up 4 minutes 0.0.0.0:27017->27017/tcp jimpython_mongo_1
I was hoping to not change the port that MySQL in Docker is running on if possible. Any input is appreciated.