connecting to a docker-compose mysql container denies access but docker running same image does not

前端 未结 7 495
情歌与酒
情歌与酒 2020-12-01 05:26

I am having some issues connecting to the mysql docker container that I have launched with docker-compose. This is a long post (sorry!).

Here is my docker-compose.ym

7条回答
  •  渐次进展
    2020-12-01 05:49

    I am using the official mysql image with docker-compose and not having a problem. The only difference in my compose file is that I am using a dictionary instead of an array:

    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_USER: django
      MYSQL_PASSWORD: secret
      MYSQL_DATABASE: myAppDB
    

    I have noticed that the compose file documentation is still stuck in V1 in some places, so you could try this, if you're using V2. Otherwise, for debugging you can use docker-compose exec to interact with the container created by compose directly.

    docker-compose exec db /bin/bash will get you a shell on the container that is giving you trouble and you can check things like SHOW GRANTS FOR django@'%' or whether the ports are being forwarded correctly. I hope this helps.

提交回复
热议问题