From 5b68e050e0f5073259fb20b3cd5cbd5cb38f53ac Mon Sep 17 00:00:00 2001 From: OmegaSquad82 <34405234+OmegaSquad82@users.noreply.github.com> Date: Thu, 9 Jun 2022 04:11:24 +0200 Subject: [PATCH] Add usage of strict shell (#1841) Co-authored-by: Rico Sta. Cruz --- dockerfile.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dockerfile.md b/dockerfile.md index 62a0a94c9..83b02e876 100644 --- a/dockerfile.md +++ b/dockerfile.md @@ -47,6 +47,20 @@ ADD file.xyz /file.xyz COPY --chown=user:group host_file.xyz /path/container_file.xyz ``` +### Run commands in strict shell + +```docker +ENV my_var +SHELL ["/bin/bash", "-euo", "pipefail", "-c"] + +# With strict mode: +RUN false # fails build like using && +RUN echo "$myvar" # will throw error due to typo +RUN true | false # will bail out of pipe +``` + +Using `shell` will turn on strict mode for shell commands. + ### Onbuild ```docker