I have an existing and working Dockerfile, that I want to update to have a better structure, and to allow me to volume-mount part of the application directory to enable persistence.
Folder structure is:
.git/ .gitignore Dockerfile README.md Sorter.py WebService.py requirements.txt
The current working Dockerfile is:
FROM python:3.8-alpine ADD . / RUN pip install -r requirements.txt EXPOSE 5000 CMD [ "python", "./WebService.py" ]
I now want to simply do this not in the root directory, so I do the following:
FROM python:3.8-alpine WORKDIR /app COPY . . RUN pip install -r requirements.txt EXPOSE 5000 ENTRYPOINT ["python"] CMD ["WebService.py"]
I build the image "docker build -t , and run it using the same docker-compose file as for the first buildscript – and I get the error:
"python: can't open file '/app/WebService.py': [Errno 2] No such file or directory"
Source: Docker Questions