I did a docker pull and can list the image that's downloaded. I want to see the contents of this image. Did a search on the net but no straight answer. Thanks.
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
We can try a simpler one as follows:
This worked in Docker version:
You can just run an interactive shell container using that image and explore whatever content that image has.
For instance:
docker run -it image_name sh
Or, if you want to see how the image was build, meaning the steps in its
Dockerfile
, you can:The steps will be logged into the
image_history
file.The accepted answer here is problematic, because there is no guarantee that an image will have any sort of interactive shell. For example, the drone/drone image contains on a single command
/drone
, and it has anENTRYPOINT
as well, so this will fail:And this will fail:
This is not an uncommon configuration; many minimal images contain only the binaries necessary to support the target service. Fortunately, there are mechanisms for exploring an image filesystem that do not depend on the contents of the image. The easiest is probably the
docker export
command, which will export a container filesystem as a tar archive. So, start a container (it does not matter if it fails or not):Then use
docker export
to export the filesystem totar
:The
docker ps -lq
there means "give me the id of the most recent docker cotnainer". You could replace that with an explicit container name or id.Docker is still under construction. The last time I checked it did not have this feature as part of the command line tools.
You can however try docker inspect on an image. You'll see a section called Data under GraphDriver. Here you have paths such as UpperDir that you can run find on.
This might not work with all storage drivers for docker.
You should not start a container just to see the image contents. For instance you might want to look for malicious content, not run it. Use "create" instead of "run";
docker create --name="tmp_$$" image:tag docker export tmp_$$ | tar t docker rm tmp_$$
With Docker EE for Windows (17.06.2-ee-6 on Hyper-V Server 2016) all contents of Windows Containers can be examined at
C:\ProgramData\docker\windowsfilter\
path of the host OS.No special mounting needed.
Folder prefix can be found by container id from
docker ps -a
output.