Skip to content

Dockerpy 1.10.6 does not provide container state information #1387

@narenst

Description

@narenst

My setup:

pip freeze | grep docker && python --version && docker version
You are using pip version 6.0.8, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
docker-py==1.10.6
docker-pycreds==0.2.1
Python 3.5.0
Client:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      linux/amd64

When I get container info using dockerpy, I can see the more information about the status of the container:

In [1]: from docker import Client

In [2]: client = Client()

In [5]: client.containers()[6]
Out[5]:
{'Command': 'docker-entrypoint.sh redis-server',
 'Created': 1482407336,
 'HostConfig': {'NetworkMode': 'compose_default'},
 'Id': '7f1aa27309769655e581ef5c9af88a3b514eee62390df0297148fd7c910ac865',
 'Image': 'redis:alpine',
 'ImageID': 'sha256:9947c5a33865d3f74c0485ce5f615499db1855584f1455976d1b41a0a9f56729',
 'Labels': {'com.docker.compose.config-hash': '726840f84c08212461057ee8713fb9858c56b7e4fbcf578ac7a47e05abe60cb9',
  'com.docker.compose.container-number': '1',
  'com.docker.compose.oneoff': 'False',
  'com.docker.compose.project': 'compose',
  'com.docker.compose.service': 'redis',
  'com.docker.compose.version': '1.8.0'},
 'Mounts': [{'Destination': '/data',
   'Driver': 'local',
   'Mode': 'rw',
   'Name': '665a50d2c5b24b7f2fba7cd62c91ed7e9d2176ac81a04d70e9a055bdcb71b62e',
   'Propagation': 'rprivate',
   'RW': True,
   'Source': '/var/lib/docker/volumes/665a50d2c5b24b7f2fba7cd62c91ed7e9d2176ac81a04d70e9a055bdcb71b62e/_data'}],
 'Names': ['/compose_redis_1'],
 'NetworkSettings': {'Networks': {'compose_default': {'Aliases': None,
    'EndpointID': '570532c37daacdeed3ad340940ac3dfafe2e3a814a5fee33c3134d4f714920e9',
    'Gateway': '172.19.0.1',
    'GlobalIPv6Address': '',
    'GlobalIPv6PrefixLen': 0,
    'IPAMConfig': None,
    'IPAddress': '172.19.0.2',
    'IPPrefixLen': 16,
    'IPv6Gateway': '',
    'Links': None,
    'MacAddress': '02:42:ac:13:00:02',
    'NetworkID': '8b86254e8f59d8400f5a2f2f4c54cd0f4b2010b93d6ede1bc25addac0a4eee51'}}},
 'Ports': [{'IP': '0.0.0.0',
   'PrivatePort': 6379,
   'PublicPort': 6379,
   'Type': 'tcp'}],
 'State': 'running',
 'Status': 'Up 7 days'}

When I inspect the same container from docker command line tool:

$ docker inspect 7f1aa27309769655e581ef5c9af88a3b514eee62390df0297148fd7c910ac865
[
    {
        "Id": "7f1aa27309769655e581ef5c9af88a3b514eee62390df0297148fd7c910ac865",
        "Created": "2016-12-22T11:48:56.418537295Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "redis-server"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 22764,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2017-01-03T00:02:48.612091619Z",
            "FinishedAt": "2017-01-02T22:51:27.150992603Z"
        },
 ...

Is it possible for me to get the "State" information especially "OOMKilled" info using docker-py?
I briefly looked at 2.0 version but I don't think this is available in there either. Thanks!

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