Signed-off-by: Amen Belayneh <amenbelayneh@gmail.com>
| ... | ... |
@@ -295,6 +295,17 @@ any point in an image's history, much like source control. |
| 295 | 295 |
The *exec* form makes it possible to avoid shell string munging, and to `RUN` |
| 296 | 296 |
commands using a base image that does not contain `/bin/sh`. |
| 297 | 297 |
|
| 298 |
+In the *shell* form you can use a `\` (backslash) to continue a single |
|
| 299 |
+RUN instruction onto the next line. For example, consider these two lines: |
|
| 300 |
+``` |
|
| 301 |
+RUN /bin/bash -c 'source $HOME/.bashrc ;\ |
|
| 302 |
+echo $HOME' |
|
| 303 |
+``` |
|
| 304 |
+Together they are equivalent to this single line: |
|
| 305 |
+``` |
|
| 306 |
+RUN /bin/bash -c 'source $HOME/.bashrc ; echo $HOME' |
|
| 307 |
+``` |
|
| 308 |
+ |
|
| 298 | 309 |
> **Note**: |
| 299 | 310 |
> To use a different shell, other than '/bin/sh', use the *exec* form |
| 300 | 311 |
> passing in the desired shell. For example, |
| ... | ... |
@@ -311,12 +322,6 @@ commands using a base image that does not contain `/bin/sh`. |
| 311 | 311 |
> If you want shell processing then either use the *shell* form or execute |
| 312 | 312 |
> a shell directly, for example: `RUN [ "sh", "-c", "echo", "$HOME" ]`. |
| 313 | 313 |
|
| 314 |
-> **Note**: |
|
| 315 |
-> If you choose to use the *shell* form, any time you want to continue a single |
|
| 316 |
-> `RUN` instruction onto the next line, it has to be ended with a backslash `\`. |
|
| 317 |
-> For example, `RUN /bin/bash -c 'source $HOME/.bashrc ;\` then on the next |
|
| 318 |
-> line ` echo $HOME '`. |
|
| 319 |
- |
|
| 320 | 314 |
The cache for `RUN` instructions isn't invalidated automatically during |
| 321 | 315 |
the next build. The cache for an instruction like |
| 322 | 316 |
`RUN apt-get dist-upgrade -y` will be reused during the next build. The |