V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
ysicing
V2EX  ›  Docker

Docker 映射端口 telnet 失败

  •  
  •   ysicing ·
    ysicing · Jun 21, 2017 · 5108 views
    This topic created in 3233 days ago, the information mentioned may be changed or developed.

    遇到一个奇怪的问题。 Mac 起了一个 docker 容器,端口情况 0.0.0.0:80>8080/tcp 但是我telnet localhost 80提示

    Trying ::1...
    telnet: connect to address ::1: Connection refused
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    telnet: Unable to connect to remote host
    
    Supplement 1  ·  Jun 21, 2017
    测试了一下跑了 nginx
    curl localhsot 直接提示连接被拒绝了,是不是 docker 没权限
    3 replies    2017-06-21 13:31:52 +08:00
    xss
        1
    xss  
       Jun 21, 2017
    容器里面要听在 0.0.0.0, 不要听在 127.0.0.1
    cloverstd
        2
    cloverstd  
       Jun 21, 2017
    我是试了

    docker run -it --rm -p 80:80 nginx

    可以在本机 curl 到 localhost/127.0.0.1

    我用的是 Docker for mac,不是 docker-machine
    ryd994
        3
    ryd994  
       Jun 21, 2017 via Android
    整个命令贴出来
    同时检查 docker log
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4851 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 09:57 · PVG 17:57 · LAX 02:57 · JFK 05:57
    ♥ Do have faith in what you're doing.