I don't have a solution yet but I believe the culprit is that pycharm uses syntax for specifying containers unsupported by your (our) setup.
Pycharm integrates with docker-compose
like this:
- docker container with helper scripts in volume is created
$ docker ps -a
...
346cc60545f6 aac5779e964d "/bin/sh" Created pycharm_helpers_PY-213.6777.50
- it creates it's own overlay. My project
docker-compose.yml
is version: 2
, pycharm's override is:
$ cat /Users/.../Library/Caches/JetBrains/PyCharm2021.3/tmp/docker-compose.override.2.yml
version: "2"
services:
app:
command:
- "python"
- "-V"
entrypoint: ""
environment:
PYTHONUNBUFFERED: "1"
restart: "no"
volumes: []
volumes_from:
- "container:346cc60545f6e7955661fc6f8f578c6f3f871a7330b068cb35224efbee05aae7:ro"
- is calls
docker-compose
with the overlay:
docker-compose \
-f /Users/.../projects/pythonProject1/docker-compose.yml \
-f /Users/.../Library/Caches/JetBrains/PyCharm2021.3/tmp/docker-compose.override.9.yml \
run --rm --no-deps app
Now if I try container:
syntax with docker run
I get an error:
$ docker run --rm -it \
--volumes-from container:346cc60545f6e7955661fc6f8f578c6f3f871a7330b068cb35224efbee05aae7:ro \
python:3.9 bash
docker: Error response from daemon: invalid mode: 346cc60545f6e7955661fc6f8f578c6f3f871a7330b068cb35224efbee05aae7:ro.
See 'docker run --help'.
With container:
prefix removed it works:
$ docker run --rm -it \
--volumes-from 346cc60545f6e7955661fc6f8f578c6f3f871a7330b068cb35224efbee05aae7:ro \
python:3.9 bash
root@0e5ba9104c62:/# mount | grep pycharm
/dev/disk/by-label/data-volume on /opt/.pycharm_helpers type ext4 (ro,relatime)
root@0e5ba9104c62:/# ls /opt/.pycharm_helpers/
Dockerfile docstring_formatter.py pockets pycharm_matplotlib_backend six.py
MathJax epydoc profiler pycodestyle.py sphinxcontrib
__pycache__ extra_syspath.py py2ipnb_converter.py pydev syspath.py
check_all_test_suite.py generator3 py2only python-skeletons third_party
conda_packaging_tool.py icon-robots.txt py3only remote_sync.py tools
coverage_runner packaging_tool.py pycharm rest_runners typeshed
coveragepy pip-20.3.4-py2.py3-none-any.whl pycharm_display setuptools-44.1.1-py2.py3-none-any.whl virtualenv.pyz
But with docker-compose.yml
version: 3
I get different error
error during connect: Get "http://unix:2375/Users/.../.colima/docker.sock/v1.24/containers/json?all=1&filters=%7B%22label%22%3A%7B%22com.docker.compose.project%3Dpythonproject1%22%3Atrue%7D%7D&limit=0": dial tcp: lookup unix on 1.1.1.1:53: no such host
Process finished with exit code 1
Pycharm's docker-compose
for 3.8 doesn't use container:
syntax anymore:
$ cat /Users/.../Library/Caches/JetBrains/PyCharm2021.3/tmp/docker-compose.override.9.yml
version: "3.8"
services:
app:
command:
- "python"
- "-V"
entrypoint: ""
environment:
PYTHONUNBUFFERED: "1"
restart: "no"
volumes:
- "pycharm_helpers_PY-213.6777.50:/opt/.pycharm_helpers"
volumes:
pycharm_helpers_PY-213.6777.50: {}
Wrapper script replacing the overlay with the one with contaner:
prefix stripped would likely help us for version: 2
, but the problem with version: 3.8
would persist.