python - docker : "Unknown instruction: VIRTUALENV'

标签 python docker boot2docker

Dockerfile:

FROM ubuntu:14.04.2

RUN apt-get -y update && apt-get upgrade -y
RUN apt-get install python build-essential python-dev python-pip python-setuptools -y
RUN apt-get install libxml2-dev libxslt1-dev python-dev -y
RUN apt-get install libpq-dev postgresql-common postgresql-client -y
RUN apt-get install openssl openssl-blacklist openssl-blacklist-extra -y
RUN apt-get install nginx -y
RUN pip install virtualenv uwsgi

ADD canonicaliser_api ~
virtualenv ~/canonicaliser_api/venv
source ~/canonicaliser_api/venv/bin/activate
pip install -r ~/canonicaliser_api/requirements.txt

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
EXPOSE 80

CMD service nginx start

构建错误:

...
Successfully installed virtualenv uwsgi
Cleaning up...
 ---> 0c141e23f725
Removing intermediate container d9fd3c20365d
Step 8 : ADD canonicaliser_api ~
 ---> 89b4fb40dba5
Removing intermediate container b0c1ad946fc4
Step 9 : VIRTUALENV 
Unknown instruction: VIRTUALENV

它应该移除那些容器吗? 为什么它没有看到 virtualenv

最佳答案

is it supposed to remove those containers?

是的。如果您出于某种原因想要保留它们,请将 --rm=false 传递给 docker build 命令。

Why isn't it seeing virtualenv?

它看到了,但是因为它在一行的开头,所以它把它当作 Dockerfile 指令,但是没有“VIRTUALENV”指令。据推测,您打算在 ADD 之后的每一行之前放置 RUN:

ADD canonicaliser_api ~
RUN virtualenv ~/canonicaliser_api/venv

# This one needs to be a single RUN so the "source" will affect pip.
RUN source ~/canonicaliser_api/venv/bin/activate && \
        pip install -r ~/canonicaliser_api/requirements.txt

关于python - docker : "Unknown instruction: VIRTUALENV',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31751703/

相关文章:

mysql - docker run mysql 图像命令不起作用 [MacBook Pro M1]

macos - Docker/Boot2Docker : Set HTTP/HTTPS proxies for docker on OS X

python - 如何使用python3分割字符串

python - 如何从 s3 存储桶获取 excel 文件并将文件再次上传到 s3 存储桶而不使用 pandas - Python

python - NameError: 全局名称 'cb' 未定义

docker - 尝试将 docker 镜像推送到私有(private)存储库时出错

python - Pandas : Replace old column values and plot new column values with respect to equations

linux - Docker 容器的运行时性能成本是多少?

Windows + Boot2Docker, 如何添加 D :\drive to be accessible from within docker?

docker - 来自守护程序 : Container CONTAINER_NAME is not running 的错误响应