Unable to open pycharm console with docker-compose based interpreter
已回答
using PyCharm 2024.2.1
System: MacOS ( Apple silicon )
Orbstack
And Using Docker Compose based Interpreter Python 3.12
app:
container_name: app
build:
context: .
dockerfile: ./docker/Dockerfilebase
restart: unless-stopped
command: "python plato/manage.py runserver 0.0.0.0:8000"
env_file:
- .env
ports:
- "8000:8000"
expose:
- 8000
depends_on:
- db
- redis
- rabbit
This is my django container, If I run it, it runs perfectly, can run pytest and other things as well,
But after spinning up my containers, when I try to open python console I get this error
This works for me if downgrade to pycharm 2023.2, but not working for this version
Error response from daemon: driver failed programming external connectivity on endpoint plato-app-run-a63f7b432235 (9b6cd54f64c7e3cdbbaf044aca0b51389ec347048875031f373b624fdf2c09ca): Bind for 0.0.0.0:8000 failed: port is already allocated
Couldn't connect to console process.
请先登录再写评论。
For a temporary solution, I created another service similar to
app
that doesn't expose any portAnd set my project interpreter as docker-compose -> selected the service `console`
This is related to the following regression: https://youtrack.jetbrains.com/issue/PY-75536/Cannot-run-Django-container-and-Python-Console-at-the-same-time. Please subscribe to receive updates.
We plan to fix it in the following minor versions. As a workaround for now, please downgrade to 2024.1.6
We apologize for the inconvenience.