dpsyssiv90846 2017-04-25 00:32
浏览 16
已采纳

无法在OSX上使用docker公开Web服务器

I have a docker image that runs a webserver and I would like to access it from my local OSX, but I'm having issues.

I start the container with: docker run -p 8000:8000 <container-name>

and I can see log messages telling me that the local server is listening on localhost:8000

I am able to get a successful response from running:

docker exec <IMAGE-ID> curl "http://localhost:8000/"

Addresses I've tried on my local OSX are:

  • http://localhost:8000/
  • http://<DOCKER-IP-172.17.0.2:8000/

Neither of those work. Any suggestions?

  • Container is built from golang:1.8
  • Docker Version: Version 17.03.1-ce-mac5 (16048)
  • MacOS Sierra: 10.12.4
  • Firewall is turned off for testing purposes

I've tried the same process on Ubuntu 16.04 and no luck their either.

  • 写回答

1条回答 默认 最新

  • dozxos6346 2017-04-25 00:43
    关注

    The newer versions of docker use vpnkit on OSX to manage the port forwarding to the containers... you should allow vpnkit through your firewall if you want to expose the container ports.

    Also, in your Go code, make sure to bind to 0.0.0.0 rather than 127.0.0.1 for your webserver code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog