本文整理匯總了Python中docker.utils方法的典型用法代碼示例。如果您正苦於以下問題:Python docker.utils方法的具體用法?Python docker.utils怎麽用?Python docker.utils使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類docker
的用法示例。
在下文中一共展示了docker.utils方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: cleanup_images
# 需要導入模塊: import docker [as 別名]
# 或者: from docker import utils [as 別名]
def cleanup_images(client, max_image_age, dry_run, exclude_set):
# re-fetch container list so that we don't include removed containers
containers = get_all_containers(client)
images = get_all_images(client)
if docker.utils.compare_version('1.21', client._version) < 0:
image_tags_in_use = {container['Image'] for container in containers}
images = filter_images_in_use(images, image_tags_in_use)
else:
# ImageID field was added in 1.21
image_ids_in_use = {container['ImageID'] for container in containers}
images = filter_images_in_use_by_id(images, image_ids_in_use)
images = filter_excluded_images(images, exclude_set)
for image_summary in reversed(list(images)):
remove_image(client, image_summary, max_image_age, dry_run)
示例2: __init__
# 需要導入模塊: import docker [as 別名]
# 或者: from docker import utils [as 別名]
def __init__(self, job_backend, cpu_cores=1, gpu_devices=None, docker_container=None):
Thread.__init__(self)
self.job_backend = job_backend
self.gpu_devices = gpu_devices
self.docker_container = docker_container
self.max_minutes = 0
self.cpu_cores = cpu_cores
job = self.job_backend.job
if 'maxTime' in job['config'] and isinstance(job['config']['maxTime'], int) and job['config']['maxTime'] > 0:
self.max_minutes = job['config']['maxTime']
self.hardware_stream = self.job_backend.git.stream_file('aetros/job/monitoring.csv')
header = ["second", "cpu", "memory"]
try:
if self.gpu_devices:
for gpu_id, gpu in enumerate(aetros.cuda_gpu.get_ordered_devices()):
if gpu_id in gpu_devices:
header.append("memory_gpu" + str(gpu['id']))
except aetros.cuda_gpu.CudaNotImplementedException: pass
if job_backend.get_job_model().has_dpu():
header += ['dpu0']
self.hardware_stream.write(simplejson.dumps(header)[1:-1] + "\n")
self.running = True
self.early_stopped = False
self.handle_max_time = True
self.client = docker.from_env()
self.docker_api = docker.APIClient(**docker.utils.kwargs_from_env())
self.stat_stream = None
self.docker_last_last_reponse = None
self.docker_last_stream_data = 0
self.docker_last_mem = None
self.docker_last_cpu = None
示例3: is_docker_library_version_atleast
# 需要導入模塊: import docker [as 別名]
# 或者: from docker import utils [as 別名]
def is_docker_library_version_atleast(version):
if utils.compare_version(docker.version, version) <= 0:
return True
return False
示例4: is_docker_api_version_atleast
# 需要導入模塊: import docker [as 別名]
# 或者: from docker import utils [as 別名]
def is_docker_api_version_atleast(docker, version):
if utils.compare_version(docker.version()['ApiVersion'], version) <= 0:
return True
return False