How to Explore Docker container’s file system

Today in this article, we will see a few approaches how to explore the docker container’s file system.
Updated October 2026: sections on stopped and shell-less containers (docker debug, export) and on docker cp, volume and diff limits, plus an FAQ.
We will see multiple methods of listing all directories and files inside the docker(run or stopped) container.
You might find the need to explore files from running containers or stopped containers on multiple occasions.
Today in this article, we will cover below aspects,
Using docker exec command to explore the file
docker exec command will run in the default directory of the container and it is mainly meant for running containers only.
Running this command on paused or stopped containers will result in an error.
Please make sure your docker running before executing the below commands.
Using Bash Shell
Command:
docker exec -it <container> bash
Let’s execute an interactive bash shell on the container.
Example
docker exec -it 1cf2eafdee49 bash
OR
docker exec -t -i 1cf2eafdee49 bash
Please note to run the below command to get the details of all files and folders in the container file.
ls -all

Using Shell or Powershell command
Command:
docker exec -it <container> sh
OR
docker exec -it <container> sh
Let’s execute an interactive bash shell on the container.
Example
docker exec -it 1cf2eafdee49 powershell
OR
docker exec -t -i 1cf2eafdee49 powershell
Using Copy Command to explore files
Alternatively, we can use the copy command to copy the containers file and use the new containers file system to explore the files.
This technique is also useful if containers are stopped or paused
docker cp <container>:<container-path> <host-path>
Below we are copying the file from the container to the host path. Once copied host path can be used to explore the files.

Below is now how you can check all the files and directory,
dir path

References:
Do you have any comments or ideas or any better suggestions to share?
Please sound off your comments below.
Happy Coding !!
Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published (2026) best practices and guidelines for software design and development.
What to Do When docker exec Fails: Stopped, Crashed or Shell-less Containers
When docker exec fails, use a tool that doesn’t have to start a program inside the container: docker cp, docker export or docker debug. The first two talk to the Docker daemon. The third brings its own shell.
Why does docker exec fail?
docker exec launches a new process inside a running container. If the container is stopped or has crashed, there’s nothing to launch it in, so you get an error.
Slim images fail differently. Distroless and scratch images ship without sh or bash, so you’ll see OCI runtime exec failed ... no such file or directory. The runtime looked for the shell binary and it isn’t there.
Note: Think of a distroless image as a sealed machine with no toolbox inside.
docker execasks the machine to hand you a screwdriver, and it has none. The analogy stops fitting fordocker cp, because that tool reaches in from outside and never asks the machine to do anything.
Which alternatives still work?
These three options cover stopped containers and shell-less images.
- docker cp: reads files through the daemon, so it works on stopped containers and images with no shell.
- docker export: streams the whole container file system as a tar archive. It skips volume contents, and if a volume is mounted over a directory you get the underlying directory instead.
- docker debug: opens a shell in any container or image, including ones without a shell. It supplies its own toolbox and leaves the image unchanged. Docker documents it as an alternative to
docker execfor slim containers.
Use docker debug when you want an interactive shell. Use docker cp or docker export when you only need to pull files out, or when docker debug isn’t available in your setup.
How do you browse an image without running it?
You can point docker debug straight at an image. It pulls the image if needed, the same way docker run does, so the app never starts.
The other route works with plain Docker commands. docker export accepts only containers, not images, so you create a container first without starting it:
- Create the container: run
docker createwith the image name. It prints a container ID and starts nothing. - Export and list: run
docker exporton that ID and pipe the output totar -tto list every path in the archive. - Clean up: remove the container with
docker rmwhen you’re done.
If you’d rather have the files on disk, docker build -o writes a build result to a local directory. It’s a good fit when you’re building the image anyway.
What about Windows containers?
Windows containers don’t have sh, so docker exec with sh or bash fails the same way. Use powershell or cmd instead. Minimal Windows base images may include only cmd.
Frequently asked questions
Why do I get ‘OCI runtime exec failed: no such file or directory’ when I exec into a container?
The image has no shell binary at the path you asked for, such as /bin/bash or /bin/sh in a distroless or scratch image. Try sh instead of bash, since many slim images ship only sh. If there’s no shell at all, use docker debug, which brings its own toolbox without changing the image. You can also use docker cp and docker export, which talk to the daemon and don’t need a shell in the container.
How do I see the files in a stopped or crashed Docker container?
docker exec can’t run in a stopped container, so you need a different route. Use docker cp to copy specific files or folders out, or use docker export to stream the whole file system as a tar archive and list it with tar -t. Volume contents won’t be in the export, so data stored on a mounted volume has to be inspected separately.
Where does Docker store a container’s files on the host?
On a Linux host with the overlay2 storage driver, docker inspect shows the GraphDriver data, and MergedDir is the container’s merged root. You need root privileges to read that path. On Docker Desktop the files live inside the Docker VM, not on your host file system, so you won’t find them by browsing your own disk.
How do I see which files changed in a container compared to its image?
Run docker diff <container> with the container name or ID. It prints A for added, C for changed and D for deleted paths. A fresh container prints nothing, and changes on volume-mapped paths aren’t listed because that data lives outside the container’s file system.