当前位置: 首页>>代码示例>>Python>>正文


Python docker.io方法代码示例

本文整理汇总了Python中docker.io方法的典型用法代码示例。如果您正苦于以下问题:Python docker.io方法的具体用法?Python docker.io怎么用?Python docker.io使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docker的用法示例。


在下文中一共展示了docker.io方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: layers

# 需要导入模块: import docker [as 别名]
# 或者: from docker import io [as 别名]
def layers(self):
        """
        similar as parent images, except that it uses /history API endpoint
        :return:
        """
        # sample output:
        # {
        #     "Created": 1457116802,
        #     "Id": "sha256:507cb13a216097710f0d234668bf64a4c92949c573ba15eba13d05aad392fe04",
        #     "Size": 204692029,
        #     "Tags": [
        #         "docker.io/fedora:latest"
        #     ],
        #     "Comment": "",
        #     "CreatedBy": "/bin/sh -c #(nop) ADD file:bcb5e5c... in /"
        # }
        try:
            response = self.d.history(self.image_id)
        except docker.errors.NotFound:
            raise NotAvailableAnymore()

        layers = []
        for l in response:
            layer_id = l["Id"]
            if layer_id == "<missing>":
                layers.append(DockerImage(l, self.docker_backend))
            else:
                layers.append(self.docker_backend.get_image_by_id(layer_id))
        return layers 
开发者ID:TomasTomecek,项目名称:sen,代码行数:31,代码来源:docker_backend.py

示例2: get_host

# 需要导入模块: import docker [as 别名]
# 或者: from docker import io [as 别名]
def get_host(self) -> str:
        return 'https://index.docker.io/v1/' 
开发者ID:zyfra,项目名称:ebonite,代码行数:4,代码来源:base.py

示例3: push

# 需要导入模块: import docker [as 别名]
# 或者: from docker import io [as 别名]
def push(self, client, tag):
        client.images.push(tag)
        logger.info('Pushed image %s to docker.io', tag) 
开发者ID:zyfra,项目名称:ebonite,代码行数:5,代码来源:base.py

示例4: delete_image

# 需要导入模块: import docker [as 别名]
# 或者: from docker import io [as 别名]
def delete_image(self, client, image: 'DockerImage', force=False, **kwargs):
        logger.warn('Skipping deleting image %s from docker.io', image.name, force, **kwargs) 
开发者ID:zyfra,项目名称:ebonite,代码行数:4,代码来源:base.py

示例5: reset_compute_engine

# 需要导入模块: import docker [as 别名]
# 或者: from docker import io [as 别名]
def reset_compute_engine():
    """Read the configuration dict at ``moldesign.compute.config`` and set up compute engine

    Sets the module-level variable ``default_engine``.

    Returns:
        dict: copy of the config dictionary used to set the engine
    """
    from moldesign import compute

    compute.default_engine = None

    if config.engine_type == 'docker':
        connect_docker()

    elif config.engine_type == 'subprocess':
        connect_subprocess()

    elif config.engine_type in ('ccc', 'docker-machine'):
        raise ValueError('Computational engine type "%s" is no longer supported by MDT. '
                         'Please install docker (https://docker.io) and set: \n'
                         '   engine_type: docker'
                         'in ~/.moldesign/moldesign.yml')

    else:
        raise ValueError('Unrecognized engine %s' % config.engine_type) 
开发者ID:Autodesk,项目名称:molecular-design-toolkit,代码行数:28,代码来源:configuration.py

示例6: run_command_in_container

# 需要导入模块: import docker [as 别名]
# 或者: from docker import io [as 别名]
def run_command_in_container(image=None, cmd="echo HELLO WORLD", fileget=None, fileput=None):
    if not image or not cmd:
        raise Exception("Invalid input: image="+str(image)+" cmd="+str(cmd))

    try:
        imageId = discover_imageId(image)
    except Exception as err:
        print str(err)
        return(list())

    olines = list()
    fbuf = ""

    try:
        docker_cli = contexts['docker_cli']
        
        container = docker_cli.create_container(image=image, command="/bin/bash -c '"+cmd+"'", tty=False)

        docker_cli.create_container(image=image, command="/bin/bash -c '"+cmd+"'", tty=False)
        if fileput:
            try:
                TFH=open(fileput, 'r')
                dat = TFH.read()
                TFH.close()
                docker_cli.put_archive(container.get('Id'), "/", dat)
            except Exception as err:
                traceback.print_exc()
                print str(err)
                pass
        response = docker_cli.start(container=container.get('Id'))
        output = docker_cli.logs(container=container.get('Id'), stdout=True, stderr=True, stream=True)
        for l in output:
            olines.append(l)

        if fileget:
            try:
                tstream,stat = docker_cli.get_archive(container, fileget)
                TFH = io.BytesIO(tstream.data)
                tar=tarfile.open(fileobj=TFH, mode='r', format=tarfile.PAX_FORMAT)
                for member in tar.getmembers():
                    fbuf = tar.extractfile(member).read()
                tar.close()
                TFH.close()
            except Exception as err:
                fbuf = ""
                pass

    except Exception as err:
        raise err
    finally:
        try:
            docker_cli.remove_container(container=container.get('Id'), force=True)
        except:
            pass

    return(olines, fbuf) 
开发者ID:anchore,项目名称:anchore,代码行数:58,代码来源:anchore_utils.py


注:本文中的docker.io方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。