Live data from Hacker News

Dockerfmt: A Dockerfile Formatter

github.com

11–20 of 67 posts

Re: Dockerfmt: A Dockerfile Formatter

#11
I had a chuckle when I looked at the source code and could not find a Dockerfile in there. I want to kick the tires on it and the easiest way would be to run it as a Docker container against an existing file and alas, I cannot.

Re: Dockerfmt: A Dockerfile Formatter

#12

I just use a yaml LSP which will probably try to lookup the schema.org Containerfile format for this. I first noticed this recently when working on a Github Actions yaml file. Pretty nifty.

But a dockerfile is not yaml. do you mean for docker compose?

You’re right. I’m sure there is a containerfile lsp however.

https://github.com/sublimelsp/LSP-dockerfile

Re: Dockerfmt: A Dockerfile Formatter

#13
post #5

Side question. Why would people continue to build new dockerfiles as opposed to using Podman ?

Dockerfile has been standardized as Containerfile: https://github.com/containers/common/blob/main/docs/Containe...

Dockerfile seems very specific to Docker still, I don’t think they have to go through a committee to add anything to the spec

https://docs.docker.com/build/buildkit/dockerfile-release-no...

If any organization adopted the spec I would hope they would at least make it adopt a standard file extension like .oci so it would at least be more easily recognizable by IDEs, I have never liked having to put the use case as the extension like Dockerfile.dev

But I do like that docker and buildkit have been able to freely evolve the spec with things like advanced caching directives that work great in buildx

Re: Dockerfmt: A Dockerfile Formatter

#14

Earlier quoted context omitted.

Podman uses Dockerfiles too. Dockerfiles is the language for specifying a set of instructions for building container images.

It's not a very good one, but it is ubiquitous (it's also better if you remember to include the right syntax marker that enables heredocs): # syntax=docker/dockerfile:1 I suspect that the GP was really asking "why not use a different tool", like buildah https://buildah.io >, buildpacks https://buildpacks.io >, nix https://nix.dev/tutorials/nixos/building-and-running-docker-... >, kaniko https://github.com/GoogleConta…

Buildah is the only serious alternative in my opinion.

You lose automatic layer caching, but in exchange you can use the same tools (RUN, ADD, etc) within a much more powerful shell environment.

I wrote a Buildah wrapper that uses a shell script harness to polyfill the familiar Dockerfile syntax while adding several extra goodies - mainly the ability to bake runtime arguments (mounts, ports...) into the image. Very handy!

Re: Dockerfmt: A Dockerfile Formatter

#15

I had a chuckle when I looked at the source code and could not find a Dockerfile in there. I want to kick the tires on it and the easiest way would be to run it as a Docker container against an existing file and alas, I cannot.

The project should certainly also be formatting its own docker file via a docker invocation

Re: Dockerfmt: A Dockerfile Formatter

#16

I had a chuckle when I looked at the source code and could not find a Dockerfile in there. I want to kick the tires on it and the easiest way would be to run it as a Docker container against an existing file and alas, I cannot.

Hi there — I’ll try to distribute a docker release of the binary tomorrow!

Re: Dockerfmt: A Dockerfile Formatter

#17
It's great to see auto-formatting continuing to become universal across all languages. As LLMs write more code, full auto-formatting helps keep diffs clean.

For anyone looking to try dockerfmt, I just added a plugin to Qlty CLI, which is available in v0.508.0. The plugin took about ten minutes to add: https://github.com/qltysh/qlty/blob/main/qlty-plugins/plugin...

Full disclosure: I'm the founder of Qlty, which produces a universal code linter and formatter, Qlty CLI (https://github.com/qltysh/qlty). It is completely free and published under a Fair Source license.

Re: Dockerfmt: A Dockerfile Formatter

#18
post #15

I had a chuckle when I looked at the source code and could not find a Dockerfile in there. I want to kick the tires on it and the easiest way would be to run it as a Docker container against an existing file and alas, I cannot.

The project should certainly also be formatting its own docker file via a docker invocation

And built in a multistage Dockerfile.
Post reply on HN