dockerfilegraph
visualizes your multi-stage Dockerfiles.
It creates a visual graph representation of the build process. The graph contains the following nodes:
- All build stages
- The default build target highlighted in grey
- External base images with dashed borders
The edges of the graph represent:
- FROM dependencies with a full arrow head
- COPY --from=... dependencies with an empty arrow head
- RUN --mount=type=cache,from=... dependencies with an empty diamond arrow head
You can add an optional legend to the graph and change the output format and resolution. For all the details, see the options below.
- A multi-stage Dockerfile file in your current working directory
Running dockerfilegraph
without any arguments will create a Dockerfile.pdf
in your current working directory. This PDF contains a visual graph representation of your multi-stage Dockerfile.
Docker / nerdctl
docker run \
--rm \
--workdir /workspace \
--volume "$(pwd)":/workspace \
ghcr.io/patrickhoefler/dockerfilegraph
docker run \
--rm \
--workdir /workspace \
--volume "$(pwd)":/workspace \
ghcr.io/patrickhoefler/dockerfilegraph:alpine
brew install patrickhoefler/tap/dockerfilegraph
dockerfilegraph
Make sure that Graphviz is installed locally.
Then:
go build
./dockerfilegraph
❯ dockerfilegraph --help
dockerfilegraph visualizes your multi-stage Dockerfile.
It outputs a graph representation of the build process.
Usage:
dockerfilegraph [flags]
Flags:
-d, --dpi int Dots per inch of the PNG export (default 96)
-h, --help help for dockerfilegraph
-l, --legend Add a legend (default false)
-o, --output Output file format. One of: canon, dot, pdf, png (default pdf)