docker: how to show the diffs between 2 images

后端 未结 8 910
走了就别回头了
走了就别回头了 2021-01-30 10:33

I have a Dockerfile with a sequence of RUN instructions that execute \"apt-get install\"s; for example, a couple of lines:

RUN apt-get install -y tree
RUN apt-ge         


        
相关标签:
8条回答
  • 2021-01-30 11:00

    Each RUN instruction creates a new container and you can inspect what a container changed by using docker diff <container>.

    So after building your dockerfile, run docker ps -a to get a list of the containers the buildfile created. It should look something like:

    CONTAINER ID  IMAGE        COMMAND               CREATED        STATUS ...
    53d7dadafee7  f71e394eb0fc /bin/sh -c apt-get i  7 minutes ago  Exit 0 ...
    ...
    

    Now you can do do docker diff 53d7dadafee7 to see what was changed.

    0 讨论(0)
  • 2021-01-30 11:05

    It sounds like in this case maybe you only needed to see the diff between two layers. If so, dive is awesome for this; it lets you inspect the filesystem at each layer and you can filter files by change type (unchanged, added, removed, modified).

    And if you want to inspect the differences between two unrelated images, having two dive processes running side by side works okay too.

    0 讨论(0)
提交回复
热议问题