mirror of
https://github.com/yeasy/docker_practice.git
synced 2024-12-27 07:26:21 +00:00
cbaa24c48f
Signed-off-by: Kang Huaishuai <khs1994@khs1994.com>
34 lines
666 B
Go
34 lines
666 B
Go
# SHELL 指令
|
||
|
||
格式:`SHELL ["executable", "parameters"]`
|
||
|
||
`SHELL` 指令可以指定 `RUN` `ENTRYPOINT` `CMD` 指令的 shell,Linux 中默认为 `["/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
|
||
```
|