docker_practice/image/dockerfile/shell.md
Kang Huaishuai cbaa24c48f
Dockerfile add shell label
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
2020-09-06 20:16:04 +08:00

34 lines
666 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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
```