docker / docker/docker-py

client.containers API documentation seems outdated

Open
#3,102 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

group/documentation kind/question
Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

Hi,

Documentation (both docs and readme.md) state that we can manage containers using client.containers API.

However when I use the following piece of code obtained from README.md:

import docker

client = docker.from_env()

container = client.containers.get('45e6d2de7c54')

I am getting the following error:

AttributeError: 'function' object has no attribute 'get'

I am getting the same thing for client.containers.list().

It seems that method signature changed.

Digging through the code I figured out that I should be able to get the container info like this:

container = client.containers(filters={"id": "45e6d2de7c54"})

However this does not return Container object on which I could do certain actions and instead returns plain dictionary with the result set which I assume is the one from Docker API.

Am I doing something wrong? Can I still get the actual container object like it is documented in the docs?

I am using version 6.0.1 installed through pip. My python version is 3.10.6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the client.containers examples in README.md and the documentation, then reproduce the reported behavior with docker.from_env() on version 6.0.1. Compare the documented calls with the library's current client API and update both documentation locations so the examples show the supported way to retrieve a Container object; verify the examples against the reported error cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.