docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Api documentation error

Open Jumbo-WJB opened this issue 2 years ago • 1 comments

hello: When I create a container with the document, it always prompts me that the api attribute does not exist: https://docker-py.readthedocs.io/en/stable/api.html image

image

After testing, I found that the api document is wrong, not client.api.create_container, it should be client.create_container.

Jumbo-WJB avatar May 30 '22 08:05 Jumbo-WJB

That sounds like you are using Docker SDK for Python version < 2.0.0 (you can get that with pip install docker-py instead of pip install docker). That was last released in November 2016. Please make sure you use a newer version of Docker SDK for Python (pip install docker).

Also note that if you installed both docker-py and docker, both will be broken. You first need to uninstall both (!) before re-installing one of them (please use docker and not docker-py).

felixfontein avatar Jun 26 '22 11:06 felixfontein

I believe this is actually an issue with the following lines: client = docker.APIclient container_id=client.api.create_container

I think you're essentially doing api.api and that's why it says APIClient object has no attribute api.

I would remove one of the api attributes from either. I think it's generally easier to do it from the first as it would give you more flexibility when using client in the future

James-Ilosta avatar Dec 30 '22 12:12 James-Ilosta