skip to Main Content

I am trying to set up a Django project in PyCharm on Ubuntu and configure the Docker Compose interpreter. However, when I try to create the interpreter (Step 6), I get the following error:

Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "Creating djanog_web_run ... ": executable file not found in $PATH: unknown

I have confirmed that the docker-compose up command runs the program properly, and my Docker Compose file looks fine. It is shown below:

version: "3.9"

services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    environment:
      - POSTGRES_NAME=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    depends_on:
      - db

I have also followed the steps to set up a Docker Compose interpreter in PyCharm (specifying the configuration files, service, and environment variables).

What could be causing this error and how can I fix it?

Dockerfile

# syntax=docker/dockerfile:1
FROM python:3
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
  • PyCharm 2022.3.3 (Professional Edition)

2

Answers


  1. If you use Docker-Desktop, make sure Compose V2 is enabled in Preferences | Build, Execution, Deployment | Docker | Tools in PyCharm.

    PyCharm - Settings - Tools

    Login or Signup to reply.
  2. Faced the same problem today. When I ran

    me@mycomputer:~/myProject$ docker run -it my-image:latest /bin/bash
    
    nobody@c2ae150852f5:/opt$ which python
    /opt/venv/bin/python
    

    I found out, that my image does not have a system interpreter, but a virtual environment. So choosing that in Step 6 and giving the path /opt/venv/bin/python I was able to connect.

    After entering the path via the 3 dots, it needs to be selected in the drop down. For me it showed as [invalid] /opt/venv/bin/python. It worked anyway.

    Using PyCharm 2022.3.3 (Professional Edition).

    Hope it helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search