我正试图通过Docker运行我的flask应用程序。我上周就开始工作了,但现在它给了我一些问题。我可以启动服务器,但似乎无法通过浏览器访问任何内容。
这是我的
app.py
文件(减少):
... imports ...
app = Flask(__name__)
DATABASE = "users.db"
app.secret_key = os.environ["SECRET_KEY"]
app.config['UPLOAD_FOLDER'] = 'static/Content'
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
__TOKEN = os.environ["dbx_access_token"]
__dbx = None
... functions ...
if __name__ == '__main__':
app.run(port=5001, threaded=True, host=('0.0.0.0'))
这是我的
Dockerfile
:
# Use an official Python runtime as a parent image
FROM python:3
# Set the working directory to /VOSW-2016-original
WORKDIR /VOSW-2016-original
# Copy the current directory contents into the container at /VOSW-2016-original
ADD . /VOSW-2016-original
# Putting a variables in the environment
ENV SECRET_KEY="XXXXXXXX"
ENV dbx_access_token="XXXXXXXX"
# Install any needed packages specified in requirements.txt
RUN pip install
# Make port 8000 available to the world outside this container
EXPOSE 8000
# Run app.py when the container launches
CMD ["python", "app.py", "--host=0.0.0.0"]
以下是我用来启动服务器的命令:
docker build -t vosw_original ./VOSW-2016-original/
然后:
docker run -i -t -p 5001:8000 vosw_original
然后我得到消息:
* Running on http://0.0.0.0:5001/ (Press CTRL+C to quit)
因此,服务器似乎正在运行,但当我执行以下任一操作时,似乎无法访问它:
-
http://0.0.0.0:5001/
-
http://0.0.0.0:8000/
-
http://127.0.0.1:5001/
-
http://127.0.0.1:8000/
我哪里出错了?