从另一个错误的主机连接mysql docker容器

时间:2016-07-02 10:36:45

标签: mysql containers

我创建了一个mysql包含器:

  $ sudo docker inspect ca3370a5a299 | grep IPAddress
    [sudo] password for danny: 
            "IPAddress": "172.17.0.42",

并将fedora容器链接到它,但是当我尝试连接到fedora容器中的mysql容器时,我总是得到错误的主机(172.17.0.47是fedora容器的IP地址):

sudo docker run -d -it  --link  ca3370a5a299:mysql fedora 

mysql  --host 172.17.0.42 -u root -p 
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'172.17.0.47' (using password: YES)

编辑: 我确保数据库正在运行,在容器本身内连接它

sudo docker exec -it  websites-mysql  bash
mysql -u root -p
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit

1 个答案:

答案 0 :(得分:0)

也许投票是因为我应该在serverfault网站上发布这个问题?无论如何我在here上发现了类似的问题,但事实证明我误解了错误。错误意味着来自fedora containet访问的用户被拒绝。