How can I inspect the file system of a failed `docker build`?

后端 未结 5 579
孤独总比滥情好
孤独总比滥情好 2020-12-12 08:38

I\'m trying to build a new Docker image for our development process, using cpanm to install a bunch of Perl modules as a base image for various projects.

<
5条回答
  •  长情又很酷
    2020-12-12 09:27

    Docker caches the entire filesystem state after each successful RUN line.

    Knowing that:

    • to examine the latest state before your failing RUN command, comment it out in the Dockerfile (as well as any and all subsequent RUN commands), then run docker build and docker run again.
    • to examine the state after the failing RUN command, simply add || true to it to force it to succeed; then proceed like above (keep any and all subsequent RUN commands commented out, run docker build and docker run)

    Tada, no need to mess with Docker internals or layer IDs, and as a bonus Docker automatically minimizes the amount of work that needs to be re-done.

提交回复
热议问题