我不确定我在这里缺少什么。 canonicaliser_api
包含我的代码和requirements.txt
。
FROM ubuntu:14.04.2
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
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 /home/ubuntu
RUN virtualenv /home/ubuntu/canonicaliser_api/venv
RUN source /home/ubuntu/canonicaliser_api/venv/bin/activate && pip install -r /home/ubuntu/canonicaliser_api/requirements.txt
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
EXPOSE 80
CMD service nginx start
当我尝试构建它时,一切都很好,直到第11步:
Step 11 : RUN source /home/ubuntu/canonicaliser_api/venv/bin/activate && pip install -r /home/ubuntu/canonicaliser_api/requirements.txt
---> Running in 7aae5bd92b70
/home/ubuntu/canonicaliser_api/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Could not open requirements file: [Errno 2] No such file or directory: '/home/ubuntu/canonicaliser_api/requirements.txt'
The command '/bin/sh -c source /home/ubuntu/canonicaliser_api/venv/bin/activate && pip install -r /home/ubuntu/canonicaliser_api/requirements.txt' returned a non-zero code: 1
但这没有意义,我已经通过ADD
在Dockerfile中添加了整个代码目录。我在这里错过了什么吗?
bash-3.2$ ls canonicaliser_api/requirements.txt
canonicaliser_api/requirements.txt
bash-3.2$
答案 0 :(得分:2)
用法是:ADD [源目录或URL] [目标目录]
您需要将文件夹名称添加到目的地:
ADD canonicaliser_api /home/ubuntu/canonicaliser_api
答案 1 :(得分:0)
复制目录时必须小心,特别是当目标目录不存在时。简而言之,这不起作用:
ADD canonicaliser_api /home/ubuntu
但这应该:
ADD canonicaliser_api /home/ubuntu/canonicaliser_api
通常,最好避免ADD
指令并改为使用COPY
。在这种情况下,它只是一个直接替代。
将来,调试这样的事情的方法是获取成功构建的最后一个图像(在这种情况下,来自ADD
行的图像)并从中启动容器。然后你可以尝试运行有问题的指令并弄清楚出了什么问题。