本文整理汇总了Python中atomic_reactor.core.DockerTasker.pull_image方法的典型用法代码示例。如果您正苦于以下问题:Python DockerTasker.pull_image方法的具体用法?Python DockerTasker.pull_image怎么用?Python DockerTasker.pull_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atomic_reactor.core.DockerTasker
的用法示例。
在下文中一共展示了DockerTasker.pull_image方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_privileged_build
# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import pull_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)
示例2: test_hostdocker_build
# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import pull_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)
示例3: test_privileged_gitrepo_build
# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import pull_image [as 别名]
def test_privileged_gitrepo_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 = 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)
assert len(results.build_logs) > 0
dt.remove_container(results.container_id)
dt.remove_image(remote_image)
示例4: test_pull_image
# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import pull_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)
示例5: test_pull_image
# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import pull_image [as 别名]
def test_pull_image(tmpdir, insecure, dockercfg):
if MOCK:
mock_docker()
dockercfg_path = None
if dockercfg:
dockercfg_path = str(tmpdir.realpath())
file_name = '.dockercfg'
dockercfg_secret_path = os.path.join(dockercfg_path, file_name)
with open(dockercfg_secret_path, "w+") as dockerconfig:
dockerconfig.write(json.dumps(dockercfg))
dockerconfig.flush()
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=insecure, dockercfg=dockercfg_path)
got_image = t.pull_image(remote_img, insecure=insecure, dockercfg_path=dockercfg_path)
assert remote_img.to_str() == got_image
assert len(t.last_logs) > 0
t.remove_image(remote_img)
示例6: InsideBuilder
# 需要导入模块: from atomic_reactor.core import DockerTasker [as 别名]
# 或者: from atomic_reactor.core.DockerTasker import pull_image [as 别名]
class InsideBuilder(LastLogger, BuilderStateMachine):
"""
This is expected to run within container
"""
def __init__(self, source, image, **kwargs):
"""
"""
LastLogger.__init__(self)
BuilderStateMachine.__init__(self)
self.tasker = DockerTasker()
# arguments for build
self.source = source
self.base_image_id = None
self.image_id = None
self.built_image_info = None
self.image = ImageName.parse(image)
# get info about base image from dockerfile
self.df_path, self.df_dir = self.source.get_dockerfile_path()
self.base_image = ImageName.parse(DockerfileParser(self.df_path).baseimage)
logger.debug("base image specified in dockerfile = '%s'", self.base_image)
if not self.base_image.tag:
self.base_image.tag = 'latest'
def pull_base_image(self, source_registry, insecure=False):
"""
pull base image
:param source_registry: str, registry to pull from
:param insecure: bool, allow connecting to registry over plain http
:return:
"""
logger.info("pulling base image '%s' from registry '%s'", self.base_image, source_registry)
self._ensure_not_built()
base_image_with_registry = self.base_image.copy()
if source_registry:
# registry in dockerfile doesn't match provided source registry
if self.base_image.registry and self.base_image.registry != source_registry:
logger.error("registry in dockerfile doesn't match provided source registry, "
"dockerfile = '%s', provided = '%s'",
self.base_image.registry, source_registry)
raise RuntimeError(
"Registry specified in dockerfile doesn't match provided one. Dockerfile: '%s', Provided: '%s'"
% (self.base_image.registry, source_registry))
base_image_with_registry.registry = source_registry
base_image = self.tasker.pull_image(base_image_with_registry, insecure=insecure)
pulled_tags = set([base_image])
if not self.base_image.registry:
response = self.tasker.tag_image(base_image_with_registry, self.base_image, force=True)
pulled_tags.add(response)
base_image = response
logger.debug("image '%s' is available", base_image)
return pulled_tags
def build(self):
"""
build image inside current environment;
it's expected this may run within (privileged) docker container
:return: image string (e.g. fedora-python:34)
"""
logger.info("building image '%s' inside current environment", self.image)
self._ensure_not_built()
logger.debug("using dockerfile:\n%s", DockerfileParser(self.df_path).content)
logs_gen = self.tasker.build_image_from_path(
self.df_dir,
self.image,
)
logger.debug("build is submitted, waiting for it to finish")
command_result = wait_for_command(logs_gen) # wait for build to finish
logger.info("build was %ssuccesful!", 'un' if command_result.is_failed() else '')
self.is_built = True
if not command_result.is_failed():
self.built_image_info = self.get_built_image_info()
# self.base_image_id = self.built_image_info['ParentId'] # parent id is not base image!
self.image_id = self.built_image_info['Id']
build_result = BuildResult(command_result, self.image_id)
return build_result
def push_built_image(self, registry, insecure=False):
"""
push built image to provided registry
:param registry: str
:param insecure: bool, allow connecting to registry over plain http
:return: str, image
"""
logger.info("pushing built image '%s' to registry '%s'", self.image, registry)
self._ensure_is_built()
if not registry:
logger.warning("no registry specified; skipping")
#.........这里部分代码省略.........