本文整理汇总了Python中docker.client.Client.restart方法的典型用法代码示例。如果您正苦于以下问题:Python Client.restart方法的具体用法?Python Client.restart怎么用?Python Client.restart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docker.client.Client
的用法示例。
在下文中一共展示了Client.restart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DockerPyClient
# 需要导入模块: from docker.client import Client [as 别名]
# 或者: from docker.client.Client import restart [as 别名]
#.........这里部分代码省略.........
if 'cpu' in entry:
kwargs['cpu_shares'] = entry['cpu']
if 'memory' in entry:
kwargs['mem_limit'] = entry['memory']
if 'entrypoint' in entry:
kwargs['entrypoint'] = entry['entrypoint']
if 'command' in entry:
kwargs['command'] = entry['command']
if 'volumes' in entry:
volumes.extend([vol['containerPath'] for vol in entry['volumes'] if 'containerPath' in vol])
volsFrom = [vol['from'] for vol in entry['volumes'] if 'from' in vol]
if len(volsFrom):
kwargs['volumes_from'] = volsFrom
if 'portMappings' in entry:
kwargs['ports'] = [p['containerPort'] for p in entry['portMappings']]
container = self.client.create_container(**kwargs)
self.docker_start(container['Id'], entry)
return container['Id']
def docker_start(self, container, entry=None):
logsBound = False
binds = {}
restart_policy = 'on-failure'
kwargs = {
'container': container,
'binds': binds
}
if entry is not None:
if 'network' in entry:
kwargs['network_mode'] = entry['network']
if 'privileged' in entry:
kwargs['privileged'] = entry['privileged']
if 'volumes' in entry:
volsFrom = []
for vol in entry['volumes']:
if 'from' in vol:
volsFrom.append(vol['from'])
continue
if not 'containerPath' in vol:
self.log.warn('No container mount point specified, skipping volume')
continue
if not 'hostPath' in vol:
# Just a local volume, no bindings
continue