Reputation: 4136
I am trying to use PyCharm for remote debugging in my django project. I have created a Dockerfile:
FROM python:3.6
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . .
RUN python manage.py makemigrations
RUN python manage.py migrate
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
And successfully used docker build -t dockering .
to create image. I can view it:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
58e102ea8aaf dockering:1.0 "python -u /opt/.p..." 11 minutes ago Created peaceful_babbage
b10984d7f177 9adf577a7852 "python manage.py ..." 12 minutes ago Exited (137) 8 minutes ago
And run it with docker run -p 8000:8000
and enter successfully my localhost:8000. When I try to do this in PyCharm however, it seems to bee unable to find correct image.
I have set up proper interpreter in settings:
And set up command:
However, when I try to run it I have:
890e40a906dd:python -u /opt/project/manage.py runserver localhost:8000 Performing system checks...
System check identified no issues (0 silenced).
You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. August 01, 2017 - 08:47:56 Django version 1.11, using settings 'dockering.settings' Starting development server at http://localhost:8000/ Quit the server with CONTROL-C.
And as you can imagine entering localhost:8000 tells me the website does not work. What have I missed?
Upvotes: 2
Views: 2010
Reputation: 877
I was running into this too. In the "run/debug configuration" you need to set the "host" to 0. That is the host that will be injected into the "runserver" command.
Upvotes: 0
Reputation: 53
I had a similar problem because my manage.py runserver
was pointing to 0.0.0.0:8000
while Django configuration, in PyCharm, pointed to localhost
. When I set them all to 0.0.0.0:8000
it worked.
Upvotes: 1