Docker Compose Django Debug

Answered

I've followed tutorial for setting up Docker Compose with remote python interpreter.

https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html#debug

Everything works well - starting and composing services, manage.py commands etc. apart from debugging. Pycharm just won't stop on specific breakpoint and prints in PyCharm status bar - "Waiting for connection"

Did anyone experienced same issue?

6 comments

Hi! Could you please create a sample project for reproducing the issue?

0

I am having the same issue with PyCharm 2018.1.1 with two different projects. 

1

I'm having exactly the same issue - latest pycharm version

1

I've just verified the following two things:

1. It did work with Pycharm 2017.3

2. It "kind of" works if you don't have an entrypoint script in your Dockerfile. If you have

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

it kind of works, if you have

ENTRYPOINT ["somescript.sh"]

and somescript.sh calls "python manage.py runserver 0.0.0.0:8000" it doesn't work.

1

It's exactly as Ckreuzberger is saying. As long as you have defined entrypoint in your Dockerfile or docker-compose, the debugger won't stop because it gets overridden by entrypoint. Once you remove it, it works perfectly.

Sharing my Docker configuration here.

Dockerfile

FROM python:3.6.2-alpine
ENV PYTHONUNBUFFERED 1

RUN apk update \
&& apk add \
bash \
curl \
build-base \
postgresql \
postgresql-dev \
postgresql-client \
libpq


RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
ADD ./ /code

EXPOSE 8000


docker-compose.yml 

version: '3'

services:

webapp:
build: ./
env_file:
- .env
ports:
- "8000:8000"
depends_on:
- database
volumes:
- .:/code/
entrypoint: "./docker/services/webapp/run-dev.sh"

run-dev.sh

#!/bin/sh
python manage.py migrate
python manage.py runserver 0.0.0.0:8000
 
2

Thank you for the detailed explanation, I created a ticket to track this problem in our bug tracker: PY-29771. Please feel free to vote/comment.

0

Please sign in to leave a comment.