finds.dev← search

// the find

jessfraz/dockfmt

★ 441 · Go · MIT · updated Jan 2024

Dockerfile format and parser. Like `gofmt` but for Dockerfiles.

dockfmt is a small Go CLI that reformats Dockerfiles for consistent whitespace and instruction casing, the same idea as gofmt but for Docker. It also bundles a few audit subcommands (base image, maintainer, stage, workdir listing) meant for scanning a pile of Dockerfiles at once rather than editing one file by hand.

It parses with moby/buildkit's actual Dockerfile parser (vendored) instead of a hand-rolled regex parser, so multi-stage builds and instruction edge cases are handled correctly. The fmt subcommand supports -d/-w/-l flags mirroring gofmt's diff/write/list conventions, which makes it trivial to drop into a CI lint step. The base/maintainer/workdir inspection commands are genuinely useful for auditing dozens of Dockerfiles across a monorepo, something most Dockerfile linters don't offer.

The README literally says 'work in progress' and tells people not to file issues, which is a clear signal there's no real support behind it despite a 2024 push date. It still has a whole subcommand for inspecting MAINTAINER, an instruction Docker deprecated in favor of LABEL years ago, showing the tool hasn't tracked current Dockerfile conventions. Dependencies are vendored under vendor/ on top of go.mod/go.sum, which bloats the repo and makes bumping the underlying buildkit parser for newer syntax (heredocs, COPY --from by name) more work than it should be. There's no config file or ignore mechanism, so you can't exclude generated or vendored Dockerfiles from a bulk fmt/list run.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →