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


Python DockerTasker.remove_image方法代码示例

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


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

示例1: test_privileged_build

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_privileged_build(caplog, source_params):
    if MOCK:
        mock_docker()

    image_name = ImageName(repo=TEST_IMAGE)
    remote_image = image_name.copy()
    remote_image.registry = LOCALHOST_REGISTRY
    m = PrivilegedBuildManager(
        "buildroot-fedora",
        {
            "source": source_params,
            "image": remote_image.to_str(),
            "parent_registry": LOCALHOST_REGISTRY,  # faster
            "target_registries_insecure": True,
            "parent_registry_insecure": True,
        },
    )
    results = m.build()
    dt = DockerTasker()
    dt.pull_image(remote_image, insecure=True)

    if source_params["provider"] == "path":
        assert_source_from_path_mounted_ok(caplog, m.temp_dir)

    assert len(results.build_logs) > 0
    # assert isinstance(results.built_img_inspect, dict)
    # assert len(results.built_img_inspect.items()) > 0
    # assert isinstance(results.built_img_info, dict)
    # assert len(results.built_img_info.items()) > 0
    # assert isinstance(results.base_img_info, dict)
    # assert len(results.base_img_info.items()) > 0
    # assert len(results.base_plugins_output) > 0
    # assert len(results.built_img_plugins_output) > 0
    dt.remove_container(results.container_id)
    dt.remove_image(remote_image)
开发者ID:TomasTomecek,项目名称:atomic-reactor,代码行数:37,代码来源:test_reactor.py

示例2: test_hostdocker_build

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_hostdocker_build(caplog, source_params):
    if MOCK:
        mock_docker()

    image_name = ImageName(repo="atomic-reactor-test-ssh-image")
    remote_image = image_name.copy()
    remote_image.registry = LOCALHOST_REGISTRY
    m = DockerhostBuildManager("buildroot-dh-fedora", {
        "source": source_params,
        "image": remote_image.to_str(),
        "parent_registry": LOCALHOST_REGISTRY,  # faster
        "target_registries_insecure": True,
        "parent_registry_insecure": True,
    })
    results = m.build()
    dt = DockerTasker()
    dt.pull_image(remote_image, insecure=True)

    if source_params['provider'] == 'path':
        assert_source_from_path_mounted_ok(caplog, m.temp_dir)

    assert len(results.build_logs) > 0
    #assert re.search(r'build json mounted in container .+"uri": %s' %
    #        os.path.join(dconstants.CONTAINER_SHARE_PATH, 'source'))
    # assert isinstance(results.built_img_inspect, dict)
    # assert len(results.built_img_inspect.items()) > 0
    # assert isinstance(results.built_img_info, dict)
    # assert len(results.built_img_info.items()) > 0
    # assert isinstance(results.base_img_info, dict)
    # assert len(results.base_img_info.items()) > 0
    # assert len(results.base_plugins_output) > 0
    # assert len(results.built_img_plugins_output) > 0
    dt.remove_container(results.container_id)
    dt.remove_image(remote_image)
开发者ID:Akasurde,项目名称:atomic-reactor,代码行数:36,代码来源:test_reactor.py

示例3: test_pull_base_image_plugin

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_pull_base_image_plugin(df_base, parent_registry, expected_w_reg, expected_wo_reg):
    if MOCK:
        mock_docker(remember_images=True)

    tasker = DockerTasker()
    workflow = DockerBuildWorkflow(MOCK_SOURCE, 'test-image')
    workflow.builder = MockBuilder()
    workflow.builder.base_image = ImageName.parse(df_base)

    assert not tasker.image_exists(BASE_IMAGE)
    assert not tasker.image_exists(BASE_IMAGE_W_REGISTRY)

    runner = PreBuildPluginsRunner(
        tasker,
        workflow,
        [{
            'name': PullBaseImagePlugin.key,
            'args': {'parent_registry': parent_registry, 'parent_registry_insecure': True}
        }]
    )

    runner.run()

    assert tasker.image_exists(BASE_IMAGE) == expected_wo_reg
    assert tasker.image_exists(BASE_IMAGE_W_REGISTRY) == expected_w_reg

    try:
        tasker.remove_image(BASE_IMAGE)
        tasker.remove_image(BASE_IMAGE_W_REGISTRY)
    except:
        pass
开发者ID:Akasurde,项目名称:atomic-reactor,代码行数:33,代码来源:test_pull_base_image.py

示例4: test_tag_by_labels_plugin

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_tag_by_labels_plugin(tmpdir, args):
    if MOCK:
        mock_docker()

    tasker = DockerTasker()
    workflow = DockerBuildWorkflow({"provider": "git", "uri": "asd"}, "test-image")
    version = "1.0"
    release = "1"
    workflow.built_image_inspect = {
        INSPECT_CONFIG: {
            "Labels": {
                "name": TEST_IMAGE,
                "version": version,
                "release": release
            }
        }
    }
    workflow.push_conf.add_docker_registry(LOCALHOST_REGISTRY, insecure=True)
    image = ImageName(repo=TEST_IMAGE,
                      tag="%s_%s" % (version, release),
                      registry=LOCALHOST_REGISTRY)

    setattr(workflow, 'builder', X)

    runner = PostBuildPluginsRunner(
        tasker,
        workflow,
        [{
            'name': TagByLabelsPlugin.key,
            'args': args,
        }]
    )
    output = runner.run()
    assert TagByLabelsPlugin.key in output.keys()

    images = [i.to_str() for i in workflow.tag_conf.images]
    primary_images = [i.to_str() for i in workflow.tag_conf.primary_images]
    unique_images = [i.to_str() for i in workflow.tag_conf.unique_images]

    if args.get('unique_tag_only'):
        assert len(workflow.tag_conf.images) == 1
        assert len(primary_images) == 0

    else:
        assert len(workflow.tag_conf.images) == 4
        assert len(primary_images) == 3

        assert ("%s:%s-%s" % (TEST_IMAGE, version, release)) in images
        assert ("%s:%s" % (TEST_IMAGE, version)) in images
        assert ("%s:latest" % (TEST_IMAGE, )) in images

        assert ("%s:%s-%s" % (TEST_IMAGE, version, release)) in primary_images
        assert ("%s:%s" % (TEST_IMAGE, version)) in primary_images
        assert ("%s:latest" % (TEST_IMAGE, )) in primary_images

    assert len(unique_images) == 1
    assert ("%s:%s" % (TEST_IMAGE, "unique_tag_123")) in images
    assert ("%s:%s" % (TEST_IMAGE, "unique_tag_123")) in unique_images
    tasker.remove_image(image)
开发者ID:vrutkovs,项目名称:atomic-reactor,代码行数:61,代码来源:test_tag_by_labels.py

示例5: test_build_image_from_git

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_build_image_from_git(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    response = t.build_image_from_git(DOCKERFILE_GIT, temp_image_name, use_cache=True)
    list(response)
    assert response is not None
    assert t.image_exists(temp_image_name)
    t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:12,代码来源:test_tasker.py

示例6: test_image_creation_local_repo

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_image_creation_local_repo():
    if MOCK:
        mock_docker()

    b = BuildImageBuilder(reactor_local_path=PARENT_DIR)
    df_dir_path = os.path.join(PARENT_DIR, 'images', 'privileged-builder')
    b.create_image(df_dir_path, TEST_BUILD_IMAGE)

    dt = DockerTasker()
    assert dt.image_exists(TEST_BUILD_IMAGE)
    dt.remove_image(TEST_BUILD_IMAGE)
开发者ID:projectatomic,项目名称:atomic-reactor,代码行数:13,代码来源:test_buildimage.py

示例7: test_tag_and_push

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_tag_and_push(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    temp_image_name.registry = LOCALHOST_REGISTRY
    temp_image_name.tag = "1"
    output = t.tag_and_push_image(INPUT_IMAGE, temp_image_name, insecure=True)
    assert output is not None
    assert t.image_exists(temp_image_name)
    t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:13,代码来源:test_tasker.py

示例8: test_tag_and_push_plugin

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_tag_and_push_plugin(tmpdir, image_name, logs, should_raise, use_secret):
    if MOCK:
        mock_docker()
        flexmock(docker.Client, push=lambda iid, **kwargs: iter(logs),
                 login=lambda username, registry, dockercfg_path: {'Status': 'Login Succeeded'})

    tasker = DockerTasker()
    workflow = DockerBuildWorkflow({"provider": "git", "uri": "asd"}, TEST_IMAGE)
    workflow.tag_conf.add_primary_image(image_name)
    setattr(workflow, 'builder', X)

    secret_path = None
    if use_secret:
        temp_dir = mkdtemp()
        with open(os.path.join(temp_dir, ".dockercfg"), "w+") as dockerconfig:
            dockerconfig_contents = {
                LOCALHOST_REGISTRY: {
                    "username": "user", "email": "[email protected]", "password": "mypassword"}}
            dockerconfig.write(json.dumps(dockerconfig_contents))
            dockerconfig.flush()
            secret_path = temp_dir


    runner = PostBuildPluginsRunner(
        tasker,
        workflow,
        [{
            'name': TagAndPushPlugin.key,
            'args': {
                'registries': {
                    LOCALHOST_REGISTRY: {
                        'insecure': True,
                        'secret': secret_path
                    }
                }
            },
        }]
    )

    if should_raise:
        with pytest.raises(Exception):
            runner.run()
    else:
        output = runner.run()
        image = output[TagAndPushPlugin.key][0]
        tasker.remove_image(image)
        assert len(workflow.push_conf.docker_registries) > 0

        if MOCK:
            # we only test this when mocking docker because we don't expect
            # running actual docker against v2 registry
            assert workflow.push_conf.docker_registries[0].digests[image_name] == DIGEST1
开发者ID:lcarva,项目名称:atomic-reactor,代码行数:54,代码来源:test_tag_and_push.py

示例9: test_build_image

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_build_image(tmpdir, source_params):
    provided_image = "test-build:test_tag"
    if MOCK:
        mock_docker(provided_image_repotags=provided_image)

    source_params.update({'tmpdir': str(tmpdir)})
    s = get_source_instance_for(source_params)
    t = DockerTasker()
    b = InsideBuilder(s, provided_image)
    build_result = b.build()
    assert t.inspect_image(build_result.image_id)
    # clean
    t.remove_image(build_result.image_id)
开发者ID:Akasurde,项目名称:atomic-reactor,代码行数:15,代码来源:test_build.py

示例10: test_commit_container

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_commit_container(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    container_id = t.run(INPUT_IMAGE, command="id")
    t.wait(container_id)
    image_id = t.commit_container(container_id, message="test message", image=temp_image_name)
    try:
        assert t.image_exists(image_id)
    finally:
        t.remove_container(container_id)
        t.remove_image(image_id)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:15,代码来源:test_tasker.py

示例11: test_pull_image

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_pull_image():
    if MOCK:
        mock_docker()

    t = DockerTasker()
    local_img = input_image_name
    remote_img = local_img.copy()
    remote_img.registry = LOCALHOST_REGISTRY
    t.tag_and_push_image(local_img, remote_img, insecure=True)
    got_image = t.pull_image(remote_img, insecure=True)
    assert remote_img.to_str() == got_image
    assert len(t.last_logs) > 0
    t.remove_image(remote_img)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:15,代码来源:test_tasker.py

示例12: test_remove_image

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_remove_image(temp_image_name):
    if MOCK:
        mock_docker(inspect_should_fail=True)

    t = DockerTasker()
    container_id = t.run(input_image_name, command="id")
    t.wait(container_id)
    image_id = t.commit_container(container_id, image=temp_image_name)
    try:
        t.remove_container(container_id)
    finally:
        t.remove_image(image_id)
    assert not t.image_exists(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:15,代码来源:test_tasker.py

示例13: test_tag_image

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_tag_image(temp_image_name):
    if MOCK:
        mock_docker()

    t = DockerTasker()
    temp_image_name.registry = "somewhere.example.com"
    temp_image_name.tag = "1"
    img = t.tag_image(INPUT_IMAGE, temp_image_name)
    try:
        assert t.image_exists(temp_image_name)
        assert img == temp_image_name.to_str()
    finally:
        t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:15,代码来源:test_tasker.py

示例14: test_build_image_from_path

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_build_image_from_path(tmpdir, temp_image_name):
    if MOCK:
        mock_docker()

    tmpdir_path = str(tmpdir.realpath())
    clone_git_repo(DOCKERFILE_GIT, tmpdir_path)
    df = tmpdir.join("Dockerfile")
    assert df.check()
    t = DockerTasker()
    response = t.build_image_from_path(tmpdir_path, temp_image_name, use_cache=True)
    list(response)
    assert response is not None
    assert t.image_exists(temp_image_name)
    t.remove_image(temp_image_name)
开发者ID:david-martin,项目名称:atomic-reactor,代码行数:16,代码来源:test_tasker.py

示例15: test_push_image

# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import remove_image [as 别名]
def test_push_image(temp_image_name, should_fail):
    if MOCK:
        mock_docker(push_should_fail=should_fail)

    t = DockerTasker()
    temp_image_name.registry = LOCALHOST_REGISTRY
    temp_image_name.tag = "1"
    t.tag_image(INPUT_IMAGE, temp_image_name)
    if should_fail:
        with pytest.raises(RuntimeError) as exc:
            output = t.push_image(temp_image_name, insecure=True)
        assert "Failed to push image" in str(exc)
    else:
        output = t.push_image(temp_image_name, insecure=True)
        assert output is not None
    t.remove_image(temp_image_name)
开发者ID:digideskio,项目名称:atomic-reactor,代码行数:18,代码来源:test_tasker.py


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