GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - patrickhoefler/dockerfilegraph: Visualize your multi-stage Dockerfiles

BranchesTags
Open more actions menu

Latest commit

 

History

815 Commits
815 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
examples
examples
 
 
internal
internal
 
 
.gitignore
.gitignore
 
 
.go-version
.go-version
 
 
.golangci.yaml
.golangci.yaml
 
 
.goreleaser.yaml
.goreleaser.yaml
 
 
AGENTS.md
AGENTS.md
 
 
CLAUDE.md
CLAUDE.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
main.go
main.go
 
 
main_test.go
main_test.go
 
 
mise.toml
mise.toml
 
 
renovate.json
renovate.json
 
 

Repository files navigation

dockerfilegraph

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

A command-line tool that visualizes multi-stage Dockerfiles as dependency graphs.

Uses Graphviz to generate visual representations of Docker build processes, helping you understand build dependencies, document architecture, and debug complex multi-stage builds.

What You Get

The generated graph includes:

Nodes:

  • All build stages
  • Default build target (highlighted in grey)
  • External images (with dashed borders)

Edges:

  • FROM ... dependencies → solid line with full arrow
  • COPY --from=... dependencies → dashed line with empty arrow
  • RUN --mount=(.*)from=... dependencies → dotted line with diamond arrow

Supports multiple output formats (PDF, SVG, PNG), a legend, and layout customization options.

Example Output

With Legend (--legend)

Example output including a legend

With Layer Visualization and Hidden Scratch Images (--layers --scratch hidden)

Example output including layers

Complex Multi-stage Build (--concentrate --nodesep 0.3 --unflatten 4)

Example output with --concentrate and --unflatten 4

Getting Started

Prerequisites

  • A multi-stage Dockerfile

Installation and Usage

Run dockerfilegraph in your project directory to generate a Dockerfile.pdf with your build graph.

Docker

docker run --rm --user "$(id -u):$(id -g)" \
  -v "$(pwd)":/workspace -w /workspace \
  ghcr.io/patrickhoefler/dockerfilegraph

Homebrew

brew install patrickhoefler/tap/dockerfilegraph
dockerfilegraph

mise

Requirements: Graphviz installed locally

mise use -g github:patrickhoefler/dockerfilegraph
dockerfilegraph

Build from Source

  • Native Build

    Requirements: mise and Graphviz

    mise install
    mise run build
    ./dockerfilegraph
  • Container Build

    Requirements: mise and Docker

    mise install
    mise run build-docker-image
    docker run \
      --rm \
      --user "$(id -u):$(id -g)" \
      --workdir /workspace \
      --volume "$(pwd)":/workspace \
      dockerfilegraph

Configuration Options

Common Flags:

  • --output svg|png|pdf - Choose your output format
  • --legend - Add a legend explaining the notation
  • --layers - Show all Docker layers
  • --separate ubuntu,alpine - Display selected external images as separate nodes per usage, reducing edge clutter
  • --target release,app - Only show stages required to build the given target(s), eliding everything else

All Available Options:

❯ 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)
      --scratch                 how to handle scratch images, one of: collapsed, hidden, separated (default collapsed)
      --separate strings        external images to display as separate nodes per usage (e.g. --separate ubuntu,alpine)
      --target strings          only show stages required to build the given target(s) (e.g. --target release,app)
  -u, --unflatten uint          stagger length of leaf edges between [1,u] (default 0)
      --version                 display the version of dockerfilegraph

Development

This project uses mise for tool version management and running common development tasks.

Quick Start:

# Install project tools
mise install

# Run linters and tests
mise run check

# Build the binary
mise run build

Run mise tasks to see all available tasks.

Contributing

Found a bug or have a feature request? Open an issue or submit a pull request.

License

MIT

About

Visualize your multi-stage Dockerfiles

Topics

clicommand-linecontainerdockerdockerfilegogolanggraphgraphvizvisualization

Resources

Readme
MIT license

Code of conduct

Code of conduct
Activity

Stars

277 stars

Watchers

4 watching

Forks

17 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.