Dockerfile add shell label

Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
pull/464/head
Kang Huaishuai 2020-09-06 20:16:04 +08:00
parent 5d91c5a39f
commit cbaa24c48f
No known key found for this signature in database
GPG Key ID: 5E515022F565DA09
6 changed files with 131 additions and 0 deletions

View File

@ -233,6 +233,8 @@ module.exports = {
'image/dockerfile/workdir',
'image/dockerfile/user',
'image/dockerfile/healthcheck',
'image/dockerfile/label',
'image/dockerfile/shell',
'image/dockerfile/onbuild',
'image/dockerfile/references',
'image/multistage-builds/',

View File

@ -41,6 +41,8 @@
* [USER ](image/dockerfile/user.md)
* [HEALTHCHECK ](image/dockerfile/healthcheck.md)
* [ONBUILD ](image/dockerfile/onbuild.md)
* [LABEL ](image/dockerfile/label.md)
* [SHELL ](image/dockerfile/shell.md)
* [](image/dockerfile/references.md)
* [Dockerfile ](image/multistage-builds/README.md)
* [ Laravel ](image/multistage-builds/laravel.md)

View File

@ -7,3 +7,62 @@
`Dockerfile` `ARG` `docker build` `--build-arg <参数名>=<值>`
1.13 `--build-arg` `Dockerfile` `ARG` `--build-arg` `Dockerfile` 使使退 1.13 退使 CI `Dockerfile` Dockerfile
ARG `FROM` `FROM`
```docker
ARG DOCKER_USERNAME=library
FROM ${DOCKER_USERNAME}/alpine
RUN set -x ; echo ${DOCKER_USERNAME}
```
使 Dockerfile `${DOCKER_USERNAME}` `FROM` `ARG`
```docker
# FROM
ARG DOCKER_USERNAME=library
FROM ${DOCKER_USERNAME}/alpine
# FROM 使
ARG DOCKER_USERNAME=library
RUN set -x ; echo ${DOCKER_USERNAME}
```
```docker
# FROM
ARG DOCKER_USERNAME=library
FROM ${DOCKER_USERNAME}/alpine
RUN set -x ; echo 1
FROM ${DOCKER_USERNAME}/alpine
RUN set -x ; echo 2
```
Dockerfile `FROM` 使 `${DOCKER_USERNAME}`使
```docker
ARG DOCKER_USERNAME=library
FROM ${DOCKER_USERNAME}/alpine
# FROM 使
ARG DOCKER_USERNAME=library
RUN set -x ; echo ${DOCKER_USERNAME}
FROM ${DOCKER_USERNAME}/alpine
# FROM 使
ARG DOCKER_USERNAME=library
RUN set -x ; echo ${DOCKER_USERNAME}
```

View File

@ -0,0 +1,17 @@
# LABEL
`LABEL` metadata
```docker
LABEL <key>=<value> <key>=<value> <key>=<value> ...
```
```docker
LABEL org.opencontainers.image.authors="yeasy"
LABEL org.opencontainers.image.documentation="https://yeasy.gitbooks.io"
```
https://github.com/opencontainers/image-spec/blob/master/annotations.md

View File

@ -0,0 +1,33 @@
# SHELL
`SHELL ["executable", "parameters"]`
`SHELL` `RUN` `ENTRYPOINT` `CMD` shellLinux `["/bin/sh", "-c"]`
```docker
SHELL ["/bin/sh", "-c"]
RUN lll ; ls
SHELL ["/bin/sh", "-cex"]
RUN lll ; ls
```
`RUN` `RUN` 退
`ENTRYPOINT` `CMD` shell `SHELL` shell shell
```docker
SHELL ["/bin/sh", "-cex"]
# /bin/sh -cex "nginx"
ENTRYPOINT nginx
```
```docker
SHELL ["/bin/sh", "-cex"]
# /bin/sh -cex "nginx"
CMD nginx
```

View File

@ -16,3 +16,21 @@ RUN echo "hello" > world.txt
`RUN` `RUN cd /app`
使 `WORKDIR`
```docker
WORKDIR /app
RUN echo "hello" > world.txt
```
`WORKDIR` 使 `WORKDIR`
```docker
WORKDIR /a
WORKDIR b
WORKDIR c
RUN pwd
```
`pwd` `/a/b/c`