Docker容器RestartCount不增加
testing
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'))
产量
从我得到的testing
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
呢? 我使用错误的字段?
正如在注释中已经指出的那样, RestartCount
字段在重启策略的上下文中被用来跟踪在失败的情况下的重启尝试。
用户重新启动时不会增加。
您可以查看泊坞窗事件以跟踪正常的容器重启。 这也适用于dockerpy 。