Consider the following typical python project structure:
fooproject
- main.py
- src/
- test/
- logs/
- Dockerfile
- .dockerignore
- README.md
The .dockerfile should prevent test/ and logs/ directories from being included in the docker image.
test/
logs/
Contents of Dockerfile are
FROM ubuntu16.04
COPY . /app/
WORKDIR /app
USER root
RUN pip install -r requirements.txt
ENTRYPOINT ["main.py"]
However, when running through PyCharm's automatic docker integration, the test and logs directories are both copied into the container. The PyCharm run command ends up as follows:
7eb643d9785b:python -u /opt/project/main.py
I've tried a few things to no avail, such as making a duplicate copy of .dockerignore at the directory above the rest of the app. For example:
COPY . /app/
COPY .dockerignore .dockerignore
WORKDIR /app
Wondering if it's possible that PyCharm's /opt/project is somehow interfering? So where exactly should .dockerignore be in a project like this?
Update
I shared the output of docker container inspect with BMitch, and he was able to find the solution. PyCharm was automatically mounting a volume in the container settings run config
