Skip to content

client.containers API documentation seems outdated #3102

Open
@jelovac

Description

@jelovac

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions