mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-25 19:25:27 +00:00
Add blank lines before headers
This commit is contained in:
@@ -38,6 +38,7 @@ RUN echo {a..z}
|
||||
默认情况下,管道命令 `cmd1 | cmd2` 只要 `cmd2` 成功,整个指令就视为成功。这可能掩盖构建错误。
|
||||
|
||||
```docker
|
||||
|
||||
## ❌ 这里的 wget 失败了,但构建继续(因为 tar 成功了)
|
||||
|
||||
RUN wget -O - https://invalid-url | tar xz
|
||||
@@ -46,6 +47,7 @@ RUN wget -O - https://invalid-url | tar xz
|
||||
使用 `SHELL` 启用 `pipefail`:
|
||||
|
||||
```docker
|
||||
|
||||
## ✅ 启用 pipefail
|
||||
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
@@ -90,11 +92,13 @@ FROM ubuntu:24.04
|
||||
RUN echo "Using sh"
|
||||
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
## 使用 bash
|
||||
|
||||
RUN echo "Using bash"
|
||||
|
||||
SHELL ["/bin/sh", "-c"]
|
||||
|
||||
## 回到 sh
|
||||
|
||||
RUN echo "Using sh again"
|
||||
|
||||
Reference in New Issue
Block a user