如何访问泊坞窗映像? [英] How to access a docker image?

查看:71
本文介绍了如何访问泊坞窗映像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图不运行而访问docker映像,我只想知道它包含的内容以进行验证。我无法将其缩进容器中,因为它仅需一秒钟即可结束,因此我需要浏览图像而不是容器。

在容器完成之前是否有访问容器的权限?

I'm trying to access a docker image without running, I just want to know what it contains for verification. I cannot ssh into the container as the it ends in just a second, so I need to explore the image and not the container. or Is there anyway to access the container before it completes?

推荐答案

实际上,这很麻烦探索图片 docker save 命令的输出不是很友好。最好使用容器。但是您不必运行容器即可执行此操作。

It's pretty cumbersome to actually explore an image. The docker save command's output isn't very friendly. You're better off working with a container. But you don't have to run a container to do this.

您可以使用 docker create 命令和一些其他命令一起运行而不探索容器:

You can use the docker create command with a few others to explore a container without running it:

docker pull alpine
docker create --name foo alpine false
docker export foo | # Export the entire filesystem as a tape archive
  tar -tf- | # Use tar to output the names of files
  less # pipe to less to page the output

如果要检查单个文件,则可以使用 docker cp ,例如:

If you want to examine a single file, you can use docker cp, like so:

docker cp foo:etc/passwd - | tar -xO | head -n3
root:x:0:0:root:/root:/bin/ash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin

您真的可以逃脱不使用最后一条语句中的管道;您会在顶部看到一些tar垃圾,但是您只是在探索就没关系。

You can really get away without using the pipeline in the last statement; you'll get some tar junk at the top, but it doesn't matter if you're just exploring.

这篇关于如何访问泊坞窗映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆