search

Home  >  Q&A  >  body text

docker容器映射端口不成功

我的Dockerfile里暴露的缺失是3000端口,运行下面指令:

docker run -P -d --name myexpress alpha/express

查看结果如下:

可我尝试访问:localhost:32768,没有结果。
但是我登进虚拟机,curl端口3000是有结果的。

所以目前我的情况是:容器内的应用(Express)跑起来了,可外部访问不到,我觉得是端口映射出问题了。
各路大神,给我出出主意吧。

PHPzPHPz2884 days ago626

reply all(4)I'll reply

  • 高洛峰

    高洛峰2017-04-24 09:14:50

    If you want to look at it this way on a mac, there is a container management software called kitematic,

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-24 09:14:50

    It seems there is a problem with the service binding address. Binding 127.0.0.1 may not receive requests from external IPs.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-24 09:14:50

    127.0.0.1 is a loopback address, which can only be accessed locally and cannot be accessed externally. So your express needs to monitor the address 0.0.0.0

    reply
    0
  • 黄舟

    黄舟2017-04-24 09:14:50

    -p IP address: host port: IP address: container port/protocol

    reply
    0
  • Cancelreply