gabrieldemarmiesse / python-on-whales

An awesome Python wrapper for an awesome Docker CLI!
MIT License
514 stars 100 forks source link

Cache-installed docker doesn't include the compose plugin #575

Open faec opened 3 months ago

faec commented 3 months ago

Using python-on-whales to orchestrate CI machines, some commands produce the following failure:

failed on setup with "python_on_whales.exceptions.DockerException: The docker command executed was `/root/.cache/python-on-whales/docker-cli/20.10.5/docker compose [...]`.
It returned with code 125
The content of stdout is ''
The content of stderr is 'unknown flag: --file

Further inspection of the error output shows that docker doesn't recognize compose as a valid command. This seems to be because python-on-whales installed the base docker engine but not the compose plugin. Manually adding the plugin as in this documentation seems to fix the issue. This is only an issue on systems that don't already have docker (with compose) installed.

I'm preparing a PR to fix this case, but any extra context or advice would be welcome.

LewisGaul commented 3 months ago

Hi @faec, one relevant point is that the plan is to remove the functionality of python-on-whales where it downloads the docker client, see https://github.com/gabrieldemarmiesse/python-on-whales/issues/512#issuecomment-1872322431.

faec commented 3 months ago

@LewisGaul Ah, thank you! In that case maybe I'll work on fixing this in our CI initialization scripts instead

alexeyda commented 3 months ago

I have the same problem. I use pytest-docker-compose-v2 which uses python-on-whales and returns the following error: It downloads docker-20-10-5.tgz

/usr/local/lib/python3.11/site-packages/python_on_whales/utils.py:194: DockerException
---------------------------- Captured stderr setup -----------------------------
100%|██████████| 69.2M/69.2M [00:06<00:00, 10.7MiB/s]s]
------------------------------ Captured log setup ------------------------------
DEBUG    urllib3.connectionpool:connectionpool.py:1055 Starting new HTTPS connection (1): download.docker.com:443
DEBUG    urllib3.connectionpool:connectionpool.py:549 https://download.docker.com:443 "GET /linux/static/stable/x86_64/docker-20.10.5.tgz HTTP/1.1" 200 69158342

and then returns the following

E           python_on_whales.exceptions.DockerException: The docker command executed was "/root/.cache/python-on-whales/docker-cli/20.10.5/docker compose --file docker-compose.yml build".
E           It returned with code 125
E           The content of stdout can be found above the stacktrace (it wasn't captured).
E           The content of stderr is 'unknown flag: --file