I'm trying to access a docker image without running, I just want to know what it contains for verification. I cannot ssh into the container as the it ends in just a second, so I need to explore the image and not the container. or Is there anyway to access the container before it completes?
Got it, here is the command:
docker run -i -t image/container /bin/bash
It's pretty cumbersome to actually explore an image. The docker save command's output isn't very friendly. You're better off working with a container. But you don't have to run a container to do this.
You can use the docker create command with a few others to explore a container without running it:
docker pull alpine
docker create --name foo alpine false
docker export foo | # Export the entire filesystem as a tape archive
tar -tf- | # Use tar to output the names of files
less # pipe to less to page the output
If you want to examine a single file, you can use docker cp, like so:
docker cp foo:etc/passwd - | tar -xO | head -n3
root:x:0:0:root:/root:/bin/ash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
You can really get away without using the pipeline in the last statement; you'll get some tar junk at the top, but it doesn't matter if you're just exploring.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With