1

Sometimes running the docker image fails so ssh’ing into the container is not an option. in that cases how do we see the content inside container?

There is a existing question but mistakenly marked as duplicate. how to browse docker image without running it?

Mahes
  • 3,610
  • 1
  • 31
  • 38
  • The duplicate target of the question you cited has a couple of examples that don't involve running the container (`docker export` trying to examine the `/var/lib/docker` content directly). Mostly, though, you do need to actually run the image in some form to look around. – David Maze Feb 10 '21 at 18:19
  • Also consider `docker run --rm -it imagename bash` to get a temporary container, running an interactive shell instead of the default image `CMD`. This will let you explore things, and also try just running what the standard command should have been and see how it fails. – David Maze Feb 10 '21 at 18:20
  • 1. I correctly stated that the question stated as duplicate is not a duplicate. – Mahes Mar 04 '21 at 16:32
  • 2. the intention of this question IS TO EXAMINE WITHOUT RUNNING THE DOCKER CONTAINER – Mahes Mar 04 '21 at 16:33

1 Answers1

0

Answering my own question.

you can add something like to override the entry point in the Dockerfile and run ls or cat command to see inside.

ENTRYPOINT ls /etc/fluentd
Mahes
  • 3,610
  • 1
  • 31
  • 38
  • 2
    You can also `docker run --rm --entrypoint ls imagename /etc/fluentd` without modifying the Dockerfile. This is kind of awkward, and you might update the Dockerfile to use `CMD` instead of `ENTRYPOINT`; then you could `docker run --rm imagename ls /etc/fluentd`. – David Maze Feb 10 '21 at 18:17