Skip to content

Commit b5d3de7

Browse files
authored
Merge pull request moby#3357 from thaJeztah/dockerfile_chown
Update builder.md to document newly supported --chmod features in both ADD and COPY statements.
2 parents 13ea5ae + 023a4f9 commit b5d3de7

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

frontend/dockerfile/docs/reference.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,20 +1129,26 @@ RUN apt-get update && apt-get install -y ...
11291129
ADD has two forms:
11301130
11311131
```dockerfile
1132-
ADD [--chown=<user>:<group>] [--checksum=<checksum>] <src>... <dest>
1133-
ADD [--chown=<user>:<group>] ["<src>",... "<dest>"]
1132+
ADD [--chown=<user>:<group>] [--chmod=<perms>] [--checksum=<checksum>] <src>... <dest>
1133+
ADD [--chown=<user>:<group>] [--chmod=<perms>] ["<src>",... "<dest>"]
11341134
```
11351135
11361136
The latter form is required for paths containing whitespace.
11371137

11381138
> **Note**
11391139
>
1140-
> The `--chown` feature is only supported on Dockerfiles used to build Linux containers,
1140+
> The `--chown` and `--chmod` features are only supported on Dockerfiles used to build Linux containers,
11411141
> and will not work on Windows containers. Since user and group ownership concepts do
11421142
> not translate between Linux and Windows, the use of `/etc/passwd` and `/etc/group` for
11431143
> translating user and group names to IDs restricts this feature to only be viable
11441144
> for Linux OS-based containers.
11451145
1146+
> **Note**
1147+
>
1148+
> `--chmod` is supported since [Dockerfile 1.3](https://docs.docker.com/build/buildkit/dockerfile-frontend/).
1149+
> Only octal notation is currently supported. Non-octal support is tracked in
1150+
> [moby/buildkit#1951](https://github.com/moby/buildkit/issues/1951).
1151+
11461152
The `ADD` instruction copies new files, directories or remote file URLs from `<src>`
11471153
and adds them to the filesystem of the image at the path `<dest>`.
11481154

@@ -1206,6 +1212,7 @@ ADD --chown=55:mygroup files* /somedir/
12061212
ADD --chown=bin files* /somedir/
12071213
ADD --chown=1 files* /somedir/
12081214
ADD --chown=10:11 files* /somedir/
1215+
ADD --chown=myuser:mygroup --chmod=655 files* /somedir/
12091216
```
12101217

12111218
If the container root filesystem does not contain either `/etc/passwd` or
@@ -1361,15 +1368,15 @@ See [`COPY --link`](#copy---link).
13611368
COPY has two forms:
13621369

13631370
```dockerfile
1364-
COPY [--chown=<user>:<group>] <src>... <dest>
1365-
COPY [--chown=<user>:<group>] ["<src>",... "<dest>"]
1371+
COPY [--chown=<user>:<group>] [--chmod=<perms>] <src>... <dest>
1372+
COPY [--chown=<user>:<group>] [--chmod=<perms>] ["<src>",... "<dest>"]
13661373
```
13671374

13681375
This latter form is required for paths containing whitespace
13691376

13701377
> **Note**
13711378
>
1372-
> The `--chown` feature is only supported on Dockerfiles used to build Linux containers,
1379+
> The `--chown` and `--chmod` features are only supported on Dockerfiles used to build Linux containers,
13731380
> and will not work on Windows containers. Since user and group ownership concepts do
13741381
> not translate between Linux and Windows, the use of `/etc/passwd` and `/etc/group` for
13751382
> translating user and group names to IDs restricts this feature to only be viable for
@@ -1437,6 +1444,7 @@ COPY --chown=55:mygroup files* /somedir/
14371444
COPY --chown=bin files* /somedir/
14381445
COPY --chown=1 files* /somedir/
14391446
COPY --chown=10:11 files* /somedir/
1447+
COPY --chown=myuser:mygroup --chmod=644 files* /somedir/
14401448
```
14411449

14421450
If the container root filesystem does not contain either `/etc/passwd` or

0 commit comments

Comments
 (0)