小编cos*_*age的帖子

Docker 容器中的 Gunicorn Flask 应用程序未暴露

容器内的应用程序无法从外部访问,即如果我执行到 docker 容器并执行

curl localhost:5000 
Run Code Online (Sandbox Code Playgroud)

它工作正常,但不能在我电脑的浏览器上运行我收到错误:无法访问此站点

我的 Dockerfile:

# Use an official Python runtime as a parent image
FROM python:3.7-slim

# Set the working directory to /app
WORKDIR /web-engine

# Copy the current directory contents into the container at /app
COPY . /web-engine

# Install Gunicorn3
RUN apt-get update && apt-get install default-libmysqlclient-dev gcc -y

# Install any needed packages specified in requirements.txt
RUN pip3 install --trusted-host pypi.python.org -r requirements.txt

# Make port 5000 available to the world outside this …
Run Code Online (Sandbox Code Playgroud)

python flask gunicorn docker kubernetes

3
推荐指数
2
解决办法
2323
查看次数

标签 统计

docker ×1

flask ×1

gunicorn ×1

kubernetes ×1

python ×1