From d5c3c1cef845cc80d5503b94b6f8cdc364f41342 Mon Sep 17 00:00:00 2001 From: Jithin James Date: Tue, 12 Apr 2022 09:43:20 +0530 Subject: [PATCH] fix: docker tag utils issues (#109) --- bentoctl/cli/__init__.py | 2 +- bentoctl/docker_utils.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bentoctl/cli/__init__.py b/bentoctl/cli/__init__.py index 03b2fdc..208c0d3 100644 --- a/bentoctl/cli/__init__.py +++ b/bentoctl/cli/__init__.py @@ -129,7 +129,7 @@ def build( """ deployment_config = DeploymentConfig.from_file(deployment_config_file) deployment_config.set_bento(bento_tag) - local_docker_tag = deployment_config.get_local_docker_tag() + local_docker_tag = deployment_config.generate_local_image_tag() with TempDirectory() as dist_dir: ( dockerfile_path, diff --git a/bentoctl/docker_utils.py b/bentoctl/docker_utils.py index b90a0ab..be06937 100644 --- a/bentoctl/docker_utils.py +++ b/bentoctl/docker_utils.py @@ -79,12 +79,22 @@ def build_docker_image( def tag_docker_image(image_name, image_tag): docker_client = docker.from_env() try: - docker_client.images.tag(image_name, image_tag) + img = docker_client.images.get(image_name) + was_tagged = img.tag("image_tag") + if not was_tagged: + raise BentoctlDockerException( + f"Failed to tag docker image! Function returned False" + ) except docker.errors.APIError as error: raise BentoctlDockerException( f"Failed to tag docker image {image_tag}: {error}" ) + except docker.errors.ImageNotFound as error: + raise BentoctlDockerException( + f"Failed to tag Docker image, {image_name} not found." + ) + def push_docker_image_to_repository( repository, image_tag=None, username=None, password=None