容器化安装greatsql,映射3306端口报错
你好,根据 文档运行greatsql 容器没问题,但3306端口未映射到宿主机上,应用连接不到容器内部 3306端口,我把3306端口通过 docker run映射出来,启动报错:
docker -v
Docker version 19.03.9, build 9d988398e7
docker pull greatsql
docker run -d --name greatsql -p 3306:3306 --hostname=greatsql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 greatsql/greatsql
181c3218d2116b705f1233c51c1e8e9e8e77c3e1ff0cf3b82c47ae935625c250
docker: Error response from daemon: driver failed programming external connectivity on endpoint greatsql (24c4bbd2cffa148962efec16d0c8d351a4d720812cb85ee9e686cda87ce9f538):(iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.17.0.2:3306 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)).
宿主机环境中确认没有其他服务进程已经抢先监听3306端口了吗,请再次确认下 yejr 发表于 2024-3-4 09:19
宿主机环境中确认没有其他服务进程已经抢先监听3306端口了吗,请再次确认下 ...
ss -nlt
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 0.0.0.0:8601 0.0.0.0:*
LISTEN 0 511 0.0.0.0:443 0.0.0.0:*
LISTEN 0 5 0.0.0.0:19200 0.0.0.0:*
LISTEN 0 511 0.0.0.0:810 0.0.0.0:*
LISTEN 0 1024 0.0.0.0:5355 0.0.0.0:*
LISTEN 0 511 0.0.0.0:80 0.0.0.0:*
LISTEN 0 1024 *:7000 *:*
LISTEN 0 1024 [::]:5355 [::]:*
LISTEN 0 1024 *:18700 *:* szhjb88 发表于 2024-3-4 09:48
ss -nlt
State Recv-Q Send-Q Loca ...
docker run -d --name greatsql -p 3306:3306 --hostname=greatsql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 greatsql/greatsql
6226686acbb03c91b81232b30026fdb11c752c5371f6a47add1429175c3f49ce
docker: Error response from daemon: driver failed programming external connectivity on endpoint greatsql (ab93ee1974324e16d85c9e9897e023360adaaa7a42a0626899ba2c7e102f2375):(iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 3306 -j DNAT --to-destination 172.17.0.2:3306 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1)). szhjb88 发表于 2024-3-4 09:49
docker run -d --name greatsql -p 3306:3306 --hostname=greatsql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 gr ...
你好,
检查宿主机的3306端口没有被占用,如果去掉端口映射,就正常。 szhjb88 发表于 2024-3-4 09:53
你好,
检查宿主机的3306端口没有被占用,如果去掉端口映射,就正常。
下面是我的操作过程,是正常的
# 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))
#
#
# 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
# 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))
# telnet 192.168.5.170 3306-- 第一次telnet,失败
Trying 192.168.5.170...
telnet: connect to address 192.168.5.170: Connection refused
# 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
# 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容器刚启动后,需要一定时间去完成初始化等工作,请耐心等几分钟后再尝试,尤其是当您的测试环境性能较低时,耗时要更久。 yejr 发表于 2024-3-4 11:24
下面是我的操作过程,是正常的
你好,
我将一些不用的docker容器清理,重启docker服务,一切正常,谢谢
页:
[1]