下面是我的操作过程,是正常的
- [root@db170 ~]# ss -lntp
- State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
- LISTEN 0 128 127.0.0.1:43789 0.0.0.0:* users:(("containerd",pid=318310,fd=15))
- LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=2773,fd=4))
- LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=2773,fd=6))
- [root@db170 ~]#
- [root@db170 ~]#
- [root@db170 ~]# docker run -d --name greatsql -p 3306:3306 --hostname=greatsql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 greatsql/greatsql
- Unable to find image 'greatsql/greatsql:latest' locally
- latest: Pulling from greatsql/greatsql
- 7a0437f04f83: Pull complete
- 84a97b40a81d: Pull complete
- 13ca3f91447f: Pull complete
- d7cc4345a5d0: Pull complete
- 624ffe2a3f44: Pull complete
- d667df229764: Pull complete
- 65e680c20d42: Pull complete
- c5765aa0e9b0: Pull complete
- 94b9e84699a0: Pull complete
- 59847cdb6d61: Pull complete
- Digest: sha256:98037c4be9b953af2464301b97bfdb16b40dc03f050cba1ca837361f837abde4
- Status: Downloaded newer image for greatsql/greatsql:latest
- 19a5f934d0d27bd92a6d26b49ca2fc5e4381c14648cfffd912d85cdab50b0325
- [root@db170 ~]# ss -lntp -- 查看监听,正常
- State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
- LISTEN 0 128 0.0.0.0:3306 0.0.0.0:* users:(("docker-proxy",pid=1243285,fd=4))
- LISTEN 0 128 127.0.0.1:43789 0.0.0.0:* users:(("containerd",pid=318310,fd=15))
- LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=2773,fd=4))
- LISTEN 0 128 [::]:3306 [::]:* users:(("docker-proxy",pid=1243293,fd=4))
- LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=2773,fd=6))
- [root@db170 ~]# telnet 192.168.5.170 3306 -- 第一次telnet,失败
- Trying 192.168.5.170...
- telnet: connect to address 192.168.5.170: Connection refused
- [root@db170 ~]# docker ps -a -- 查看映射,正常
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 19a5f934d0d2 greatsql/greatsql "/docker-entrypoint.…" 54 seconds ago Up 48 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060-33061/tcp greatsql
- [root@db170 ~]# telnet 192.168.5.170 3306 -- 第二次成功,因为初始化好了
- Trying 192.168.5.170...
- Connected to 192.168.5.170.
- Escape character is '^]'.
- M
- 8.0.25-1b{#lr_{�+mc}Lcaching_sha2_password^]
- telnet>
- 2#08S01Got timeout reading communication packetsConnection closed by foreign host.
复制代码
可能的原因:GreatSQL Docker容器刚启动后,需要一定时间去完成初始化等工作,请耐心等几分钟后再尝试,尤其是当您的测试环境性能较低时,耗时要更久。 |