How to see docker image contents

前端 未结 9 1143
说谎
说谎 2020-11-30 16:18

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.

相关标签:
9条回答
  • 2020-11-30 16:29

    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.

    0 讨论(0)
  • 2020-11-30 16:31

    There is a free open source tool called Anchore that you can use to scan container images. This command will allow you to list all files in a container image

    anchore-cli image content myrepo/app:latest files

    https://anchore.com/opensource/

    0 讨论(0)
  • 2020-11-30 16:34

    We can try a simpler one as follows:

    docker image inspect image_id
    

    This worked in Docker version:

    DockerVersion": "18.05.0-ce"
    
    0 讨论(0)
  • 2020-11-30 16:43

    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 following for images with an entrypoint

    docker run -it --entrypoint sh image_name
    

    Or, if you want to see how the image was build, meaning the steps in its Dockerfile, you can:

    docker image history --no-trunc image_name > image_history
    

    The steps will be logged into the image_history file.

    0 讨论(0)
  • 2020-11-30 16:44

    To list the detailed content of an image you have to run docker run --rm image/name ls -alR where --rm means remove as soon as exits form a container.

    0 讨论(0)
  • 2020-11-30 16:47
    docker save nginx > nginx.tar
    tar -xvf nginx.tar
    

    Following files are present:

    • manifest.json – Describes filesystem layers and name of json file that has the Container properties.
    • .json – Container properties
    • – Each “layerid” directory contains json file describing layer property and filesystem associated with that layer. Docker stores Container images as layers to optimize storage space by reusing layers across images.

    https://sreeninet.wordpress.com/2016/06/11/looking-inside-container-images/

    OR

    you can use dive to view the image content interactively with TUI

    https://github.com/wagoodman/dive

    0 讨论(0)
提交回复
热议问题