2016-09-20 53 views
1

嗨,剛剛發出的「你好世界」打印在http://192.168.99.100:8000/而不是http://0.0.0.0:8000/local:8000Docker:輸出顯示在http://192.168.99.100:8000/而不是http://0.0.0.0: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" 
+0

「Listening at:http://0.0.0.0」表示「正在監聽每個本地地址/主機名」,請參閱[This SO Question](http://serverfault.com/questions/78048/whats-the-difference- between-ip-address-0-0-0-0-and-127-0-0-1)以獲取詳細信息 – PeterT

+0

感謝PeterT!我現在明白,但爲什麼然後本地:8000或0.0.0.0:8000不能顯示?我該如何解決這個問題? – user3368526

回答

0

你似乎是使用泊塢窗機,考慮到你的IP端口暴露,這意味着所有的碼頭工人,端口上的docker-machine ip結果暴露出來。這是因爲所有的容器都運行在docker-machine使用的虛擬機中(可能在VirtualBox中作爲VM提供者)。

如果您想將此端口公開到0.0.0.0或本地主機,您需要確保您轉發VirtualBox VM中的端口用於任何碼頭機。這需要在VM網絡設置下添加端口。

+0

嗨恩德蘭,感謝您的評論!我明白這一點,但我怎麼能解決這個問題?你能給我這個程序嗎?我試圖谷歌它,但不能真的找到答案呢.. – user3368526

+0

@ user3368526你能解決這個問題嗎? – enderland