I'm trying to run two separate mysql containers.
(我正在尝试运行两个单独的mysql容器。)
However, I'm able to connect only to the client_mysql
container from the host (using the port 20001).
(但是,我只能从主机(使用端口20001)连接到client_mysql
容器。)
The server_mysql
container is listening on the port 20002 but it's refusing connection. (server_mysql
容器正在侦听端口20002,但拒绝连接。)
What settings do I need to change to be able to connect to both mysql containers at the same time?
(我需要更改哪些设置才能同时连接到两个mysql容器?)
My docker-compose-dev.yml
:
(我docker-compose-dev.yml
:)
version: '3'
services:
client_mysql:
image: mysql:5.7
container_name: client_mysql
ports:
- 20001:3306
volumes:
- ./_data/client_mysql:/var/lib/mysql
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=1
- MYSQL_DATABASE=client_database
server_mysql:
image: mysql:5.7
container_name: server_mysql
ports:
- 20002:3306
volumes:
- ./_data/server_mysql:/var/lib/mysql
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=1
- MYSQL_DATABASE=server_database
Output from lsof -i -P
(filtered docker mysql ports):
(lsof -i -P
输出(已过滤的docker mysql端口):)
89:com.docke 93244 petrhejda 24u IPv6 0xd067260469a7469b 0t0 TCP *:20002 (LISTEN)
90:com.docke 93244 petrhejda 26u IPv6 0xd067260469a73b1b 0t0 TCP *:20001 (LISTEN)
ask by PetrHejda translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…