dockerfilegraph
visualizes your multi-stage Dockerfiles.
It uses Graphviz to create a visual representation of the build process. The build graph contains the following nodes:
- All build stages
- The default build target (highlighted in grey)
- External images (with dashed borders)
The edges of the build graph represent:
FROM ...
dependencies (with a solid line and a full arrow head)COPY --from=...
dependencies (with a dashed line and an empty arrow head)RUN --mount=(.*)from=...
dependencies (with a dotted line and 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
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 run \
--rm \
--user "$(id -u):$(id -g)" \
--workdir /workspace \
--volume "$(pwd)":/workspace \
ghcr.io/patrickhoefler/dockerfilegraph
docker run \
--rm \
--user "$(id -u):$(id -g)" \
--workdir /workspace \
--volume "$(pwd)":/workspace \
ghcr.io/patrickhoefler/dockerfilegraph:alpine
brew install patrickhoefler/tap/dockerfilegraph
dockerfilegraph
Make sure that Graphviz is installed locally.
Then:
toolctl install dockerfilegraph
dockerfilegraph
Make sure that Graphviz is installed locally.
Then:
make build
./dockerfilegraph
❯ dockerfilegraph --help
dockerfilegraph visualizes your multi-stage Dockerfile.
It creates a visual graph representation of the build process.
Usage:
dockerfilegraph [flags]
Flags:
-c, --concentrate concentrate the edges (default false)
-d, --dpi uint dots per inch of the PNG export (default 96)
-e, --edgestyle style of the graph edges, one of: default, solid (default default)
-f, --filename string name of the Dockerfile (default "Dockerfile")
-h, --help help for dockerfilegraph
--layers display all layers (default false)
--legend add a legend (default false)
-m, --max-label-length uint maximum length of the node labels, must be at least 4 (default 20)
-n, --nodesep float minimum space between two adjacent nodes in the same rank (default 1)
-o, --output output file format, one of: canon, dot, pdf, png, raw, svg (default pdf)
-r, --ranksep float minimum separation between ranks (default 0.5)
-u, --unflatten uint stagger length of leaf edges between [1,u] (default 0)
--version display the version of dockerfilegraph