Skip to content

Commit 40b981c

Browse files
Rui Valimrnjudge
authored andcommitted
Add functionality to pull local images with skopeo
Skopeo has support for local images but Tern currently always pulls the image provided by the user from a repository. This change adds parsing to skopeo.py to enable pulling of local images using skopeo. In order to pull local images, users must prefix their image with `docker-daemon:`. Instructions in the `report` menu have also been updated with instructions on how to pull local images. Resolves #1191 Signed-off-by: Rui Valim <[email protected]> Signed-off-by: Rose Judge <[email protected]>
1 parent c5919fa commit 40b981c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

tern/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ def main():
180180
" image")
181181
parser_report.add_argument('-i', '--image',
182182
help="A container image referred either by "
183-
" repo:tag or repo@digest-type:digest")
183+
" repo:tag or repo@digest-type:digest. To "
184+
"analyze a local image, prefix the container "
185+
"image with 'docker-daemon:'")
184186
parser_report.add_argument('--no-tls', default=False,
185187
action='store_true',
186188
help="When fetching an image, DO NOT use HTTPS "

tern/load/skopeo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def pull_image(image_tag_string, no_tls=False):
3333
check_skopeo_setup()
3434
# we will assume the docker transport for now
3535
remote = f'docker://{image_tag_string}'
36+
# Unless the user specifies that the image is local
37+
if image_tag_string.split(':')[0] == "docker-daemon":
38+
remote = image_tag_string
3639
local = f'dir:{rootfs.get_working_dir()}'
3740
logger.debug("Attempting to pull image \"%s\"", image_tag_string)
3841
if no_tls:
@@ -52,6 +55,8 @@ def get_image_digest(image_tag_string):
5255
# check if skopeo is set up
5356
check_skopeo_setup()
5457
remote = f'docker://{image_tag_string}'
58+
if image_tag_string.split(':')[0] == "docker-daemon":
59+
remote = image_tag_string
5560
logger.debug("Inspecting remote image \"%s\"", image_tag_string)
5661
result, error = rootfs.shell_command(
5762
False, ['skopeo', 'inspect', remote])

0 commit comments

Comments
 (0)