6

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)
Nori
  • 2,340
  • 1
  • 18
  • 41
  • Your Ubuntu host should already have a Python interpreter. Can you use that directly? (It still make sense to use Docker for a project-specific database.) – David Maze Jan 04 '23 at 14:05
  • I usually create and develop docker-compose interpreter on Mac. I would like to port my development environment to Ubuntu. Therefore, using Python directly on Ubuntu is not an option for me. I followed this manual to set it up, but I get the above error at step 6. https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html#docker-compose-remote – Nori Jan 04 '23 at 15:38
  • I have the same error, i am trying to set up a vanilla python project, so no django – Jan Jan 07 '23 at 16:56
  • Hello Jan! I think this error happen on any docker images. – Nori Jan 08 '23 at 01:26

2 Answers2

8

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

PyCharm - Settings - Tools

helvete
  • 2,455
  • 13
  • 33
  • 37
look-in44
  • 106
  • 3
1

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!

micha
  • 321
  • 3
  • 16