构建检查
BuildKit 内置支持基于一组预定义规则分析您的构建配置,以强制执行 Dockerfile 和构建最佳实践。遵循这些规则有助于避免错误,并确保您的 Dockerfile 具有良好的可读性。
检查作为构建调用运行,但它不会产生构建输出,而是执行一系列检查以验证您的构建是否违反了任何规则。要运行检查,请使用--check标志:
$ docker build --check .
要了解更多关于如何使用构建检查的信息,请参阅 检查您的构建配置。
| Name | Description |
|---|---|
| StageNameCasing | Stage names should be lowercase |
| FromAsCasing | The 'as' keyword should match the case of the 'from' keyword |
| NoEmptyContinuation | Empty continuation lines will become errors in a future release |
| ConsistentInstructionCasing | All commands within the Dockerfile should use the same casing (either upper or lower) |
| DuplicateStageName | Stage names should be unique |
| ReservedStageName | Reserved words should not be used as stage names |
| JSONArgsRecommended | JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals |
| MaintainerDeprecated | The MAINTAINER instruction is deprecated, use a label instead to define an image author |
| UndefinedArgInFrom | FROM command must use declared ARGs |
| WorkdirRelativePath | Relative workdir without an absolute workdir declared within the build can have unexpected results if the base image changes |
| UndefinedVar | Variables should be defined before their use |
| MultipleInstructionsDisallowed | Multiple instructions of the same type should not be used in the same stage |
| LegacyKeyValueFormat | Legacy key/value format with whitespace separator should not be used |
| RedundantTargetPlatform | Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior |
| SecretsUsedInArgOrEnv | Sensitive data should not be used in the ARG or ENV commands |
| InvalidDefaultArgInFrom | Default value for global ARG results in an empty or invalid base image name |
| FromPlatformFlagConstDisallowed | FROM --platform flag should not use a constant value |
| CopyIgnoredFile (experimental) | Attempting to Copy file that is excluded by .dockerignore |
| InvalidDefinitionDescription (experimental) | Comment for build stage or argument should follow the format: `# |