首页 > 解决方案 > robomongo 无法连接到 docker mongo 容器

问题描述

我在我的VPS上通过 docker 运行 mongo 映像。

sudo docker run --rm --name db -p 27017:27017 mongo

并尝试通过 robomongo 连接到 mongodb 实例,我在我的 mongo 实例中看到接受 robomongo 连接但 robomongo 无法连接并保持加载的连接日志。我ufw的 is enableand allowed for incomingand outgoing. docker --versionDocker version 19.03.13, build 4484c46d9d

当我尝试连接时,我得到了这个日志

{"t":{"$date":"2020-11-26T09:45:58.665+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"<REMOVED>:52954","connectionId":1,"connectionCount":1}}{"t":{"$date":"2020-11-26T09:45:58.667+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn1","msg":"client metadata","attr":{"remote":"<REMOVED>:52954","client":"conn1","doc":{"application":{"name":"robo3t"},"driver":{"name":"MongoDB Internal Client","version":"4.0.5-18-g7e327a9017"},"os":{"type":"Linux","name":"Ubuntu","architecture":"x86_64","version":"20.04"}}}}

它是我的sudo iptables -L -v输出:

Chain INPUT (policy ACCEPT 63 packets, 4140 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    8  1024 DOCKER-USER  all  --  any    any     anywhere             anywhere            
    8  1024 DOCKER-ISOLATION-STAGE-1  all  --  any    any     anywhere             anywhere            
    3   429 ACCEPT     all  --  any    docker0  anywhere             anywhere             ctstate RELATED,ESTABLISHED
    1    60 DOCKER     all  --  any    docker0  anywhere             anywhere            
    4   535 ACCEPT     all  --  docker0 !docker0  anywhere             anywhere            
    0     0 ACCEPT     all  --  docker0 docker0  anywhere             anywhere            
    0     0 ACCEPT     all  --  any    docker_gwbridge  anywhere             anywhere             ctstate RELATED,ESTABLISHED
    0     0 DOCKER     all  --  any    docker_gwbridge  anywhere             anywhere            
    0     0 ACCEPT     all  --  docker_gwbridge !docker_gwbridge  anywhere             anywhere            
    0     0 ACCEPT     all  --  any    br-28cff8103d27  anywhere             anywhere             ctstate RELATED,ESTABLISHED
    0     0 DOCKER     all  --  any    br-28cff8103d27  anywhere             anywhere            
    0     0 ACCEPT     all  --  br-28cff8103d27 !br-28cff8103d27  anywhere             anywhere            
    0     0 ACCEPT     all  --  br-28cff8103d27 br-28cff8103d27  anywhere             anywhere            
    0     0 DROP       all  --  docker_gwbridge docker_gwbridge  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT 51 packets, 8916 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain DOCKER (3 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    4   535 DOCKER-ISOLATION-STAGE-2  all  --  docker0 !docker0  anywhere             anywhere            
    0     0 DOCKER-ISOLATION-STAGE-2  all  --  docker_gwbridge !docker_gwbridge  anywhere             anywhere            
    0     0 DOCKER-ISOLATION-STAGE-2  all  --  br-28cff8103d27 !br-28cff8103d27  anywhere             anywhere            
    8  1024 RETURN     all  --  any    any     anywhere             anywhere            

Chain DOCKER-ISOLATION-STAGE-2 (3 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DROP       all  --  any    docker0  anywhere             anywhere            
    0     0 DROP       all  --  any    docker_gwbridge  anywhere             anywhere            
    0     0 DROP       all  --  any    br-28cff8103d27  anywhere             anywhere            
    4   535 RETURN     all  --  any    any     anywhere             anywhere            

Chain DOCKER-USER (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    8  1024 RETURN     all  --  any    any     anywhere             anywhere

标签: linuxmongodbdockeriptablesrobo3t

解决方案


推荐阅读