Docker: How to install a virtual disk and install require.txt?

I'm not sure what I am missing here. canonicaliser_api contains my code and 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 

When I try to build it, everything will be fine until step 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 

But this does not make sense, I added the entire code directory to the Dockerfile via ADD . Did I miss something?

 bash-3.2$ ls canonicaliser_api/requirements.txt canonicaliser_api/requirements.txt bash-3.2$ 
+4
source share
2 answers

Usage: ADD [source directory or URL] [destination directory]

You need to add the folder name to the destination:

 ADD canonicaliser_api /home/ubuntu/canonicaliser_api 
+2
source

You must be careful when copying directories, especially if the target directory does not exist. In short, this will not work:

 ADD canonicaliser_api /home/ubuntu 

But this should:

 ADD canonicaliser_api /home/ubuntu/canonicaliser_api 

In general, it is best to avoid ADD instructions and use COPY . In this case, it is just a direct replacement.

In the future, a way to debug such things is to make the last image that was successfully built (in this case, one of the ADD lines) and run the container from it. Then you can try to run the problem statement and find out what is wrong.

0
source

All Articles