du7999 2017-06-02 17:56 采纳率: 100%
浏览 863
已采纳

Docker应用程序无法访问在另一个容器中运行的MySQL

I am trying to bring up a dockerized instance of Testlink (LAMP application) and connect it to an instance of MYSQL running in another container.

$ sudo docker network create mynetwork

Instantiate the container with MySQL

$ docker run -d --name mysql -p 3306:3306 --network mynetwork -v /Users/dockervol/mysql:/var/lib/mysql -e 'MYSQL_ROOT_NAME=root' -e 'MYSQL_ROOT_PASSWORD=password' mysql

Instantiate the container with Testlink

$ docker run -d -p 80:80 --network mynetwork --name testlink suzukishunsuke/testlink

When I access http://localhost/testlink and follow the standard installation tests it seems to work. The two containers are linked but when testlink tries to login to mysql it says Access denied.

Access denied for user 'root'@'156.18.0.2' (using password: YES)
  • 写回答

1条回答 默认 最新

  • douwen7603 2017-06-02 18:30
    关注

    Bear in mind that the mysql image only set the password that you provide with that environment variable when it starts for the first time (when it initializes its data directory).

    So, if you think that this is your case, empty your mysql data volume (loosing the data) and start it again, or set the root password manually.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 关于注册表摄像头和麦克风的问题
  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?
  • ¥20 双系统开机引导中windows系统消失问题?
  • ¥15 小程序准备上线,软件开发公司需要提供哪些资料给甲方