How to avoid create /opt/project

I am trying to configure a simple python project using Docker and docker-compose.

Dockerfile:

FROM python:2.7
WORKDIR /app
COPY ./requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY ./web web/
COPY ./crawler crawler/
EXPOSE 5000
CMD ["python", "/app/web/app.py"]

Docker-compose:

version: "3.0"
services:
app:
container_name: app
build:
context: .
ports:
- 5000:5000
volumes:
- "./web:/app/web"
- "./crawler:/app/crawler"

 

The pycharm configuration:

 

 

 

I follow the steps and when I inspect my container, it contains my whole project duplicated,  in /app and in /opt/project.  There is another volume from my root project to /opt/project.

How could I avoid that? 

I am looking for the right way to be able to debug my project with docker using pycharm.

 

6 comments
Comment actions Permalink

Hi,

You COPY your project files to the container using Dockerfile, and on top of that you're using volume bindings to mount your project root to the container.

You probably should choose only one of those methods of delivering your code to the container.

Check your path mappings. If you're using Dockerfile's COPY instruction, you don't need volume bindings and path mappings in PyCharm.

0
Comment actions Permalink

That's right! I do not have to COPY ./web web/ and ./crawler crawler/, but it does not solve the problem.

 

Now, I have made a few changes and I only have one volume, but when I inspect my container I still have one volume duplicated in /opt/project and I would like not to have it.

 

 

Dockerfile:

FROM python:2.7
WORKDIR /app
COPY ./requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
CMD ["python", "/app/web/app.py"]

 

Docker Compose: 

version: "3.0"
services:
app:
container_name: app
build:
context: .
ports:
- 5000:5000
volumes:
- "./:/app"

 

Pycharm configuration:

 

 

 

 

0
Comment actions Permalink

What happens if you rebuild and run the container in terminal outside of PyCharm. Do you get the same bindings?

0
Comment actions Permalink

No, when I run thorugh docker-compose up -d I only have my volume and it works fine.

I want to use PyCharm with Run/Debug Configuration

 

0
Comment actions Permalink

Please try to delete and recreate the docker interpreter. Does it help?

0
Comment actions Permalink

No, it still happens.

0

Please sign in to leave a comment.