我正在尝试将一个简单的flask应用程序移至docker,但是我无法弄清楚为什么无法从浏览器访问该应用程序。
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/app
environment:
FLASK_APP: api
FLASK_ENV: development
redis:
image: "redis:alpine"
FROM python:3.7
ADD . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["flask", "run"]
def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True)
...
return app
web_1 | * Serving Flask app "api" (lazy loading)
web_1 | * Environment: development
web_1 | * Debug mode: on
web_1 | * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
web_1 | * Restarting with stat
web_1 | * Debugger is active!
web_1 | * Debugger PIN: 277-205-758
但是当我进入浏览器时:
The connection was reset
任何想法为何?我看不到丢失的内容,因为服务器正在运行,但是它确实会立即重置连接...
答案 0 :(得分:1)
尝试
import subprocess
subprocess.run(
["netsh", "interface", "ip", "set", "dns", "Ethernet0", "static", "8.8.8.8"])