How to list files in a stopped Docker container

前端 未结 6 1281
深忆病人
深忆病人 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 21:05

    This answer to another question shows how to start a stopped container with another command. Here are the commands to list files in a stopped container.

    1. Commit the stopped container to a new image: test_image.
      • docker commit $CONTAINER_ID test_image
    2. Run the new image in a new container with a shell.
      • docker run -ti --entrypoint=sh test_image
    3. Run the list file command in the new container.
      • docker exec --privileged $NEW_CONTAINER_ID ls -1 /var/log

提交回复
热议问题