How to list files in a stopped Docker container

前端 未结 6 1266
深忆病人
深忆病人 2021-02-03 20:25

This question shows how to copy files out of a stopped container. This requires that I know the full path to the file including its file name. I know the directory I want to c

6条回答
  •  生来不讨喜
    2021-02-03 20:59

    Try using container-diff with the --type=file option. This will compare two images and report the files added, deleted and modified.

    If a file did not change since the container was started, then you would have to know the contents of the original image that started the container. So, this answer is not ideal but avoids creating an image and running it.

    This tool requires that you first create an image of the stopped Docker container with docker commit.

    Here is the command to install it:

    curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 \
        && chmod +x container-diff-linux-amd64 \
        && mkdir -p $HOME/bin \
        && export PATH=$PATH:$HOME/bin \
        && mv container-diff-linux-amd64 $HOME/bin/container-diff
    

    Here is the command to use the utility:

    container-diff analyze $IMAGE --type=file
    

提交回复
热议问题