【发布时间】:2017-10-31 14:13:35
【问题描述】:
所以我试图在 docker 容器上的 virtualenv 内运行烧瓶应用程序。
我的 Dockerfile 看起来像这样
FROM ubuntu:latest
MAINTAINER Gabriel Togni "togni@nmmi.edu"
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential python-virtualenv
COPY . /app
WORKDIR /app
RUN virtualenv test
WORKDIR test
RUN /bin/bash -c "source test/bin/activate; pip install -r requirements.txt"
ENTRYPOINT /bin/bash -c "source test/bin/activate; python app.py"
它构建没有错误,它运行没有错误,但它不工作。
我的requirements.txt 文件只有Flask==0.12.2,而我的app.py看起来像这样
from flask import Flask
import sys
app = Flask(__name__)
@app.route("/")
def hello():
if getattr(sys, "real_prefix", None) is not None:
return "Maybe in a virtualenv"
else:
return "Probably not in a virtualenv"
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')
我正在尝试在 Ubuntu Server 16.04.3 LTS 上执行此操作
编辑--
在我将; 添加到我的代码后,问题得到了解决
RUN /bin/bash -c "source test/bin/activate; pip install -r requirements.txt"
ENTRYPOINT /bin/bash -c "source test/bin/activate; python app.py"
【问题讨论】:
标签: python ubuntu docker flask dockerfile