@@ -50,10 +50,41 @@ Note that running programs as PID 1 means the program now has the special
50
50
responsibilities and behaviors associated with PID 1 in Linux, such as reaping
51
51
child processes.
52
52
53
- Alternatively, if you want to ignore this lint rule because you do want your
54
- executable to be invoked via a shell, you can use the
55
- [ ` SHELL ` ] ( https://docs.docker.com/reference/dockerfile/#shell ) Dockerfile
56
- instruction to explicitly specify a shell to use.
53
+ ### Workarounds
54
+
55
+ There might still be cases when you want to run your containers under a shell.
56
+ When using exec form, shell features such as variable expansion, piping (` | ` )
57
+ and command chaining (` && ` , ` || ` , ` ; ` ), are not available. To use such
58
+ features, you need to use shell form.
59
+
60
+ Here are some ways you can achieve that. Note that this still means that
61
+ executables run as child-processes of a shell.
62
+
63
+ #### Create a wrapper script
64
+
65
+ You can create an entrypoint script that wraps your startup commands, and
66
+ execute that script with a JSON-formatted ` ENTRYPOINT ` command.
67
+
68
+ ✅ Good: the ` ENTRYPOINT ` uses JSON format.
69
+
70
+ ``` dockerfile
71
+ FROM alpine
72
+ RUN apk add bash
73
+ COPY --chmod=755 <<EOT /entrypoint.sh
74
+ # !/usr/bin/env bash
75
+ set -e
76
+ my-background-process &
77
+ my-program start
78
+ EOT
79
+ ENTRYPOINT ["/entrypoint.sh" ]
80
+ ```
81
+
82
+ #### Explicitly specify the shell
83
+
84
+ You can use the [ ` SHELL ` ] ( https://docs.docker.com/reference/dockerfile/#shell )
85
+ Dockerfile instruction to explicitly specify a shell to use. This will suppress
86
+ the warning since setting the ` SHELL ` instruction indicates that using shell
87
+ form is a conscious decision.
57
88
58
89
✅ Good: shell is explicitly defined.
59
90
0 commit comments