容器部署时报warning

使用docker-compose.yml通过docker-compose部署,启动时报错:

seafile-docs-mysql | 2019-06-04  9:30:57 159 [Warning] Access denied for user 'root'@'172.18.0.4' (using password: YES)

但是172.18.0.4是容器:seafileltd/seafile-docs:latest的IP,非常不解的是,数据库在seafile-docs-mysql (172.18.0.3)容器中,为啥要去连seafileltd/seafile-docs:latest容器的数据库IP?

[root@cottage ~]# docker ps
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS              PORTS                        NAMES
78ecbe10d31a        seafileltd/seafile-docs:latest   "/sbin/my_init -- ..."   6 minutes ago       Up 6 minutes        0.0.0.0:3008->3008/tcp       seafile-docs
b88cef8cf4c1        mariadb:10.3                     "docker-entrypoint..."   6 minutes ago       Up 6 minutes        127.0.0.1:3306->3306/tcp     seafile-docs-mysql
aa8a7d13ff17        memcached:1.4-alpine             "docker-entrypoint..."   About an hour ago   Up 6 minutes        127.0.0.1:11211->11211/tcp   seafile-docs-memcached

[root@cottage ~]# docker inspect 78ecbe10d31a | grep 172.18
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.4",
[root@cottage ~]# docker inspect b88cef8cf4c1 | grep 172.18
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.3",
[root@cottage ~]# docker inspect  aa8a7d13ff17 | grep 172.18
                    "Gateway": "172.18.0.1",
                    "IPAddress": "172.18.0.2",
[root@cottage ~]#

这个报错不是链接docs上得mysql,而是mysql拒绝来自docs得链接请求,你没有理解报错的意思。

了解了。没有问题了,谢谢

记录个吧:这个好像是由于默认设置的数据库连接时间超级短,如果数据库没初始完成seafile就去连接的话,就会报错;解决方法:增加超时时间 7~30s即可
在 seafile:environment:- DB_ROOT_PASSWD=db_dev 一行下面增加如下:

  • DB_CONNECT_TIMEOUT=30000