Skip to content

Commit c958c68

Browse files
Merge pull request moby#5287 from dvdksn/doc-check-directive
2 parents abe8c2b + 1310470 commit c958c68

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

frontend/dockerfile/docs/reference.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,25 @@ and don't show up as build steps. Parser directives are written as a
118118
special type of comment in the form `# directive=value`. A single directive
119119
may only be used once.
120120
121+
The following parser directives are supported:
122+
123+
- [`syntax`](#syntax)
124+
- [`escape`](#escape)
125+
- [`check`](#check) (since Dockerfile v1.8.0)
126+
121127
Once a comment, empty line or builder instruction has been processed, BuildKit
122128
no longer looks for parser directives. Instead it treats anything formatted
123129
as a parser directive as a comment and doesn't attempt to validate if it might
124130
be a parser directive. Therefore, all parser directives must be at the
125131
top of a Dockerfile.
126132
127-
Parser directives aren't case-sensitive, but they're lowercase by convention.
128-
It's also conventional to include a blank line following any parser directives.
129-
Line continuation characters aren't supported in parser directives.
133+
Parser directive keys, such as `syntax` or `check`, aren't case-sensitive, but
134+
they're lowercase by convention. Values for a directive are case-sensitive and
135+
must be written in the appropriate case for the directive. For example,
136+
`#check=skip=jsonargsrecommended` is invalid because the check name must use
137+
Pascal case, not lowercase. It's also conventional to include a blank line
138+
following any parser directives. Line continuation characters aren't supported
139+
in parser directives.
130140
131141
Due to these rules, the following examples are all invalid:
132142
@@ -308,6 +318,46 @@ Successfully built 01c7f3bef04f
308318
PS E:\myproject>
309319
```
310320

321+
### check
322+
323+
```dockerfile
324+
# check=skip=<checks|all>
325+
# check=error=<boolean>
326+
```
327+
328+
The `check` directive is used to configure how [build checks](https://docs.docker.com/build/checks/)
329+
are evaluated. By default, all checks are run, and failures are treated as
330+
warnings.
331+
332+
You can disable specific checks using `#check=skip=<check-name>`. To specify
333+
multiple checks to skip, separate them with a comma:
334+
335+
```dockerfile
336+
# check=skip=JSONArgsRecommended,StageNameCasing
337+
```
338+
339+
To disable all checks, use `#check=skip=all`.
340+
341+
By default, builds with failing build checks exit with a zero status code
342+
despite warnings. To make the build fail on warnings, set `#check=error=true`.
343+
344+
```dockerfile
345+
# check=error=true
346+
```
347+
348+
To combine both the `skip` and `error` options, use a semi-colon to separate
349+
them:
350+
351+
```dockerfile
352+
# check=skip=JSONArgsRecommended;error=true
353+
```
354+
355+
To see all available checks, see the [build checks reference](https://docs.docker.com/reference/build-checks/).
356+
Note that the checks available depend on the Dockerfile syntax version. To make
357+
sure you're getting the most up-to-date checks, use the [`syntax`](#syntax)
358+
directive to specify the Dockerfile syntax version to the latest stable
359+
version.
360+
311361
## Environment replacement
312362

313363
Environment variables (declared with [the `ENV` statement](#env)) can also be

frontend/dockerfile/docs/rules/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ the rules. To run a check, use the `--check` flag:
2020
$ docker build --check .
2121
```
2222

23+
To learn more about how to use build checks, see
24+
[Checking your build configuration](https://docs.docker.com/build/checks/).
25+
2326
<table>
2427
<thead>
2528
<tr>

frontend/dockerfile/linter/docs/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ the rules. To run a check, use the `--check` flag:
2020
$ docker build --check .
2121
```
2222

23+
To learn more about how to use build checks, see
24+
[Checking your build configuration](https://docs.docker.com/build/checks/).
25+
2326
<table>
2427
<thead>
2528
<tr>

0 commit comments

Comments
 (0)