Dockerfile 格式和解析器,以及 dockfmt 的现代版本。构建于内部 buildkit 解析器之上。
二进制文件可从发布页面获取。
用法
A updated version of the dockfmt. Uses the dockerfile parser from moby/buildkit and the shell formatter from mvdan/sh.
Usage:
dockerfmt [Dockerfile] [flags]
dockerfmt [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
version Print the version number of dockerfmt
Flags:
-c, --check Check if the file(s) are formatted
-h, --help help for dockerfmt
-i, --indent uint Number of spaces to use for indentation (default 4)
-n, --newline End the file with a trailing newline
-w, --write Write the formatted output back to the file(s)
Use "dockerfmt [command] --help" for more information about a command.
限制
RUN
析器目前不支持命令中的分组或分号- 较长的 JSON 命令不会进行换行
- 不支持
# escape=X
指令
特点
- Format
RUN
steps with https://github.com/mvdan/sh - 支持基本的 heredocs:
RUN <<EOF
echo "hello"
echo "world"
EOF
- 支持运行步骤中的基本内联注释:
RUN echo "hello" \
# this is a comment
&& echo "world"
RUN echo "hello" \
# this is a comment
# that spans multiple lines
&& echo "world"
评论