'How do I inspect the stopped docker container files

Step 1:

docker ps -a

container Id: dd5cf6b519b4

I need to inspect inside the stopped docker container which is cannot start.

I tried with docker exec -it container-id bin/bash But this is for running container.



Solution 1:[1]

$ docker ps -a

CONTAINER ID   IMAGE   COMMAND     CREATED         STATUS                    NAMES
0dfd54557799   ubuntu  "/bin/bash" 25 seconds ago  Exited (1) 4 seconds ago  peaceful_feynman

Commit the stopped image
$ docker commit 0dfd54557799 debug/ubuntu

now we have a new image
$ docker images
REPOSITORY    TAG     IMAGE ID       CREATED         SIZE  
debug/ubuntu  <none>  cc9db32dcc2d   2 seconds ago   64.3MB

create a new container from the "broken" image
$ docker run -it --rm --entrypoint sh debug/ubuntu


inside of the container we can inspect - for example, the file system
$ ls /app    
App.dll
App.pdb
App.deps.json

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1