I have a Docker image that I pulled from Docker hub.
When I run docker run image_name
, container exits immediately.
I don't have access to the source code of the Docker image, including Dockerfile. All I have is an image I pulled from hub.docker.com
.
I need to debug/see what is inside the image (e.g. see and explore image's filesystem), without running it as a container.
Is it possible?
Another approach to see "inside" without having to
run
a container would be:See the docs here.
This doesn't give you the option to list directories and files but you can get a first picture of what's inside without running a container (which might be risky if the owner has published a malicious image).
Example with the
nginx:latest
image:You can do this by changing the ENTRYPOINT of the Dockerfile to run /bin/bash instead of the ENTRYPOINT / CMD.
this will make a new image that u can login and run the application on your own (nice for debugging in case the original image exits)
Then build the image:
And run:
Alternatively, you can add --entrypoint /bin/bash to the docker exec command args
Start a container from desired image like this:
docker run -it --rm image_name bash
-i
Keeps STDIN open even if not attached-t
Allocates a pseudo-tty--rm
prunes stopped container after exitbash
executes the specific command in the container. You can execute any valid command.Example
docker run -it --rm centos:7 pwd
outputs/
(root directory).Update: In some cases, where image's entrypoint uses
bash/sh -c
format above command(docker run -it --rm image_name bash
) will not work becausebash
will be treated as additional argument to image's orignal entrypoint.In such case you can use the
--entrypoint
flag for achieving the same result: