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
?
答案 0 :(得分:3)
它应该删除那些容器吗?
是。如果由于某种原因想要保留它们,请将--rm=false
传递给docker build
命令。
为什么它没有看到
virtualenv
?
它正在看到它,但因为它在一行的开头,它将它视为Dockerfile指令,但没有" VIRTUALENV"指令。据推测,您打算在RUN
之后的每一行之前放置ADD
:
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