I'm setting up a website, I have the backend set up using Django and Gunicorn, and I am trying to package the whole thing in a docker container. I am using docker 17.05.0-ce
edge on Ubuntu 17.04 Zesty. For some reason, even though the directory mysite
has the Dockerfile
, Django app, requirements.txt
, start.sh
(on github here), the docker build stops at ADD requirements.txt /app/src/requirements.txt
.
# Dockerfile
# FROM base image to build upon
FROM phusion/baseimage
# RUN install python and pip
RUN apt-get update
RUN apt-get install -y python python-pip python-dev
# ADD requirements.txt and RUN pip to install them
ADD requirements.txt /app/src/requirements.txt
WORKDIR /app/src
RUN pip install -r requirements.txt
# EXPOSE port 8000 to allow communication to/from server
EXPOSE 8000
# CMD execute start.sh to start the server running.
WORKDIR /app/src/mysite
CMD ["/start.sh"]
# done!
I navigate to 'mysite', run docker build - < Dockerfile
and it stops on the line where it copies requirements.txt
and i get the following error:
Sending build context to Docker daemon 2.048kB
Step 1/9 : FROM phusion/baseimage
---> 877509368a8d
Step 2/9 : RUN apt-get update
---> Using cache
---> adcb4b9e8b08
Step 3/9 : RUN apt-get install -y python python-pip python-dev
---> Using cache
---> 8dbbd3e010d5
Step 4/9 : ADD requirements.txt /app/src/requirements.txt
lstat requirements.txt: no such file or directory
Which, to me, says that I'm doing this all wrong.
You are not sending a context to the docker daemon to build your project.
Use this:
docker build -t invent_an_image_name /path/to/mysite
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With