Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

mysql - Docker:多个mysql容器(Docker: multiple mysql containers)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solved:

(解决了:)

My firewall was blocking the port 20002.

(我的防火墙阻止了端口20002。)

Of course checking the firewall was the first idea I got after right after posting the question.

(当然,检查防火墙是我在发布问题后马上想到的第一个想法。)

:)

(:))


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...