OSDN Git Service

Regular updates
[twpd/master.git] / dockerfile.md
index 82b5d9f..83b02e8 100644 (file)
@@ -3,7 +3,7 @@ title: Dockerfile
 category: Devops
 layout: 2017/sheet
 prism_languages: [docker]
-updated: 2018-03-17
+updated: 2019-10-20
 ---
 
 ## Reference
@@ -22,6 +22,11 @@ ENV APP_HOME /myapp
 RUN mkdir $APP_HOME
 ```
 
+```docker
+ARG APP_HOME=""
+RUN mkdir $APP_HOME
+```
+
 ### Initialization
 
 ```docker
@@ -42,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