我正在端口5000上公开的Docker容器中运行基于Flask的API,但是甚至没有请求到达该API。
-p 5000:5000
即可运行API首选端口。不要使用HTTPS,而是在容器上安装ssh。 (因此,除非您使用像我这样的自定义Dockerfile,否则您将需要启用SUDO)http GET http://localhost:5000/customers/1
)-> 此操作失败,并根据不同的错误消息Python based urlib request (IOError: ('http protocol error', 0, 'got a bad status line', None))
http: error: ConnectionError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /filterReplies/aaaaa/aaaa (Caused by <class 'http.client.RemoteDisconnected'>: Remote end closed connection without response)
)wget http://localhost:5000
(获取Connecting to localhost (localhost)|127.0.0.1|:5000... connected.
HTTP request sent, awaiting response... No data received.
Retrying.
)和wget http://localhost:1234
(获取Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8888... failed: Connection refused.
)有所不同,因此端口在某种程度上是开放的,但是似乎没有什么在等待侧? [全部归功于ipinak,他建议将应用程序绑定到0.0.0.0
,这确实解决了问题。
app.run(host='0.0.0.0')
是重要位。 这将解决HTTP request sent, awaiting response... No data received.
问题。