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
呢?我使用了错误的字段吗?