I'm new to docker and creating a simple test app to test my docker container, but docker unable to locate the server.py
file.
The directory structure of my project is:
<project>
|
|-- Dockerfile
|-- app
|
|-- requirements.txt
|-- server.py
Below is the Dockerfile
content:
FROM ubuntu:latest
MAINTAINER name <[email protected]>
COPY . /app # do I need this ?
COPY ./app/requirements.txt /tmp/requirements.txt
RUN apt-get -y update && \
apt-get install -y python-pip python-dev build-essential
RUN pip install -r /tmp/requirements.txt
WORKDIR /app
RUN chmod +x server.py # ERROR: No such file or directory
EXPOSE 5000
ENTRYPOINT ["python"]
CMD ["server.py"] # ERROR: No such file or directory
I'm using boot2docker on windows.
What am I missing here?
You're copying your local /app/
folder to the /app/
folder in the running Docker container (as mentioned in the comments) creating /app/app/server.py
in the Docker container.
A simple fix will be to change
COPY . /app
to
COPY ./app/server.py /app/server.py
The command COPY
works as follows:
COPY <LOCAL_FROM> <DOCKER_TO>
You're selecting everything in the folder where the Dockerfile resides, by using .
in your first COPY
, thereby selecting the local /app
folder to be added to the Docker's folder. The destination you're allocating for it in the Docker container is also /app
and thus the path in the running container becomes /app/app/..
explaining why you can't find the file.
Have a look at the Docker docs.
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