Python docker.utils() Examples
The following are 4
code examples of docker.utils().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
docker
, or try the search function
.
Example #1
Source File: docker_gc.py From docker-custodian with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: MonitorThread.py From aetros-cli with MIT License | 5 votes |
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
Example #3
Source File: docker_utils.py From magnum with Apache License 2.0 | 5 votes |
def is_docker_library_version_atleast(version): if utils.compare_version(docker.version, version) <= 0: return True return False
Example #4
Source File: docker_utils.py From magnum with Apache License 2.0 | 5 votes |
def is_docker_api_version_atleast(docker, version): if utils.compare_version(docker.version()['ApiVersion'], version) <= 0: return True return False