mysql docker 2003_Docker MySQL connection refused on different port

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值