du7999
2017-06-02 17:56
浏览 781

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)

图片转代码服务由CSDN问答提供 功能建议

我正在尝试调出一个Docker化的Testlink实例(LAMP应用程序)并将其连接到一个运行MYSQL的实例 在另一个容器中。

  $ sudo docker network create mynetwork 
   
 
 

使用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 =密码'mysql 
   
 
 

使用Testlink实例化容器

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

当我访问 http:// localhost / testlink 并按照标准安装测试进行操作。 两个容器是链接的,但当testlink尝试登录到mysql时,它表示访问被拒绝。

 访问被拒绝用户'root'@'156.18.0.2'(使用密码:是 )
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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.

    打赏 评论

相关推荐 更多相似问题