iamthad / dockerfilegraph

Visualize your multi-stage Dockerfiles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dockerfilegraph

GitHub Workflow Status Go Report Card GitHub release (latest SemVer) GitHub

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 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.

Example Output

Including --legend

Example output including a legend


Including --layers

Example output including layers

Getting Started

Prerequisites

Installation and Usage

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

Image based on Ubuntu 22.10
docker run \
  --rm \
  --user "$(id -u):$(id -g)" \
  --workdir /workspace \
  --volume "$(pwd)":/workspace \
  ghcr.io/patrickhoefler/dockerfilegraph
Image based on Alpine Linux
docker run \
  --rm \
  --user "$(id -u):$(id -g)" \
  --workdir /workspace \
  --volume "$(pwd)":/workspace \
  ghcr.io/patrickhoefler/dockerfilegraph:alpine

Homebrew

brew install patrickhoefler/tap/dockerfilegraph
dockerfilegraph

toolctl

toolctl install dockerfilegraph
dockerfilegraph

Build from Source

Make sure that Graphviz is installed locally.

Then:

make build
./dockerfilegraph

More Options

❯ 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)
  -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)
  -o, --output            output file format, one of: canon, dot, pdf, png (default pdf)
      --version           display the version of dockerfilegraph

License

MIT

About

Visualize your multi-stage Dockerfiles

License:MIT License


Languages

Language:Go 94.7%Language:Dockerfile 4.0%Language:Makefile 1.3%