Docker:输出显示在http://192.168.99.100:8000/而不是http://0.0.0.0:8000/

时间:2016-09-20 06:39:06

标签: docker docker-compose

您好,我只想说“{hello world”打印在http://192.168.99.100:8000/而不是http://0.0.0.0:8000/local:8000

虽然它正在收听:http://0.0.0.0:8000(1)。我想知道为什么会这样。有谁知道如何解决这一问题?谢谢!

终端输出:

[2016-09-19 03:56:50 +0000] [1] [INFO] Starting gunicorn 19.4.5
[2016-09-19 03:56:50 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2016-09-19 03:56:50 +0000] [1] [INFO] Using worker: sync
[2016-09-19 03:56:50 +0000] [9] [INFO] Booting worker with pid: 9
192.168.99.1 - - [19/Sep/2016:04:08:25 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Kitematic/0.9.5 Chrome/45.0.2454.85 Electron/0.35.4 Safari/537.36"
192.168.99.1 - - [19/Sep/2016:04:08:30 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Kitematic/0.9.5 Chrome/45.0.2454.85 Electron/0.35.4 Safari/537.36"
192.168.99.1 - - [19/Sep/2016:04:08:39 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Kitematic/0.9.5 Chrome/45.0.2454.85 Electron/0.35.4 Safari/537.36"

192.168.99.1 - - [19/Sep/2016:04:08:43 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Kitematic/0.9.5 Chrome/45.0.2454.85 Electron/0.35.4 Safari/537.36"
[2016-09-19 04:09:14 +0000] [1] [INFO] Starting gunicorn 19.4.5
[2016-09-19 04:09:14 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2016-09-19 04:09:14 +0000] [1] [INFO] Using worker: sync
[2016-09-19 04:09:14 +0000] [9] [INFO] Booting worker with pid: 9
192.168.99.1 - - [19/Sep/2016:04:09:30 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.27 Safari/537.36"
192.168.99.1 - - [19/Sep/2016:04:09:31 +0000] "GET /favicon.ico HTTP/1.1" 404 233 "http://192.168.99.100:8000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.27 Safari/537.36"
[2016-09-19 04:10:27 +0000] [1] [INFO] Starting gunicorn 19.4.5
[2016-09-19 04:10:27 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2016-09-19 04:10:27 +0000] [1] [INFO] Using worker: sync
[2016-09-19 04:10:27 +0000] [9] [INFO] Booting worker with pid: 9
[2016-09-19 04:13:47 +0000] [1] [INFO] Starting gunicorn 19.4.5
[2016-09-19 04:13:47 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2016-09-19 04:13:47 +0000] [1] [INFO] Using worker: sync
[2016-09-19 04:13:47 +0000] [9] [INFO] Booting worker with pid: 9
192.168.99.1 - - [19/Sep/2016:04:13:52 +0000] "GET / HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.27 Safari/537.36"

1 个答案:

答案 0 :(得分:0)

考虑到您的端口所暴露的IP,您似乎正在使用docker-machine,这意味着所有docker-ports都会显示在docker-machine ip的结果上。这是因为所有容器都在docker-machine使用的虚拟机内运行(可能在VirtualBox中作为VM提供程序)。

如果要将此端口公开给0.0.0.0或localhost,您需要确保在您的VirtualBox VM中转发端口以用于您的docker-machine。这需要在VM网络设置下添加端口。