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.
1

For a temporary solution, I created another service similar to app that doesn't expose any port

  console:
    container_name: console
    build:
      context: .
      dockerfile: ./docker/Dockerfilebase
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - db
      - redis
      - rabbit

And set my project interpreter as docker-compose -> selected the service `console`

0

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.

0

请先登录再写评论。