本文整理匯總了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