Docker container exploration and you

Today I went on a journey.

I was looking to contribute a PR to an opensource project I like, and in order to do so, I need to take an existing Dockerfile, make my updates, build locally and then explore the end results.

The edits went well, no problems there.

Next I do a docker build . -t the-thing:latest - and it built just fine.

Then I went to run it, and it failed immediately. Huh? why did that happen?

So I started by using dive to explore the container image. It's a great tool for exploring each layer in a docker container, however, I wanted to look at the actual files themselves (in this case /var/www/). Dive does not support this feature (perhaps it could!)

Some how I ended up dropping a few keywords into a search, and landed here: https://www.baeldung.com/ops/docker-container-filesystem - I was familiar with a number of the techniques used in the article, though one in particular stuck out to me:

# find your container hash
docker ps -a

# to copy everything from / into a local folder ./test
docker cp <hash>:/ ./test

BINGO! I was now exploring the results of my container build, and was able to assess why things weren't working quite right in my PR.


Tools mentioned:

Dive: https://github.com/wagoodman/dive