我的 Dockerfile 内容如下:
FROM ubuntu:18.04
RUN apt-get -y update
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update -y
RUN apt-get install -y python3.7 build-essential python3-pip
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
RUN pip3 install pipenv
COPY . /app
WORKDIR /app
RUN pipenv install
EXPOSE 5000
CMD ["pipenv", "run", "python3", "application.py"]
当我执行docker build -t flask-sample:latest .
时,它构建成功(我想)。
我使用docker run -d -p 5000:5000 flask-sample
运行,并且看起来正常。
但是当我访问http://localhost:5000
时,没有加载任何内容。我做错了什么?
Running on http://127.0.0.1:5000/
,如果您看到这个消息,则无法从外部访问容器。在Docker中部署最小的flask应用程序-服务器连接问题更详细地描述了这一点。如果这没有帮助,查看实际的容器日志和足够的应用程序源代码以重现问题将非常有用。 - David Maze