Docker debug a large image layer

456 views Asked by At

I am building a docker file and noticed one of the layers (while pushing) is over 1GB.

How can I debug what files exist in a specific layer to find the offending file which I need to add to .dockerignore?

1

There are 1 answers

0
Miguel Garcia On

I think this tool could be helpful https://github.com/wagoodman/dive It allows you to inspect each layer.

You can run the tool also inside docker, mounting the docker sock, if you prefer not to install it.

Example to inspect ubuntu:20.04 image layers and contents:

 docker run --rm -it \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wagoodman/dive:latest ubuntu:20.04