Docker容器RestartCount没有递增

时间:2017-02-22 16:36:14

标签: docker dockerpy

测试

def test_can_pop_new_container(self):
    config = {
        'ip': '10.49.0.2',
        'subnet': '10.49.0.0/16',
        'gateway': '10.49.0.202',
        'vlan': 102,
        'hostname': 'test-container',
    }
    container = container_services.pop_new_container(config, self.docker_api)

    inspection = self.docker_api.inspect_container(container.get('Id'))
    print('before', inspection.get('RestartCount'), inspection.get('StartedAt'))
    container_services.restart(container, self.docker_api)
    new_inspection = self.docker_api.inspect_container(container.get('Id'))
    print('after', new_inspection.get('RestartCount'), new_inspection.get('StartedAt'))

代码

def restart(container, docker_client):
    return docker_client.restart(container.get('Id'))

输出

从测试中我得到了

before 0 None
after 0 None

从确认容器重新启动的docker ps开始。

CONTAINER ID        IMAGE                                                 COMMAND                  CREATED             STATUS              PORTS               NAMES
86f16438ffdd        docker.akema.fr:5000/coaxis/coaxisopt_daemon:latest   "/usr/bin/supervis..."   28 seconds ago      Up 17 seconds                           confident_dijkstra

问题

为什么RestartCount仍然在0呢?我使用了错误的字段吗?

0 个答案:

没有答案