teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

修正

2020/05/17 04:23

投稿

退会済みユーザー
answer CHANGED
@@ -5,9 +5,8 @@
5
5
  追記欄にてヒントもいただきましたので、タイトルに対しての一応の回答を記述しておきます。
6
6
 
7
7
  # 前提
8
- [Dockerfile リファレンス - CMD](http://docs.docker.jp/v1.11/engine/reference/builder.html#cmd)
9
- > 注釈
10
- シェル 形式と異なり、 exec 形式はコマンド・シェルを呼び出しません。つまり、通常のシェルによる処理が行われません。例えば CMD [ "echo", "$HOME" ] は $HOME の変数展開を行いません。シェルによる処理を行いたい場合は、 シェル 形式を使うか、あるいはシェルを直接使います。例: CMD [ "sh", "-c", "echo", "$HOME" ] 。
8
+ [Dockerfile reference - CMD](https://docs.docker.com/engine/reference/builder/#cmd)
9
+ > Unlike the shell form, the exec form does not invoke a command shell. This means that normal shell processing does not happen. For example, CMD [ "echo", "$HOME" ] will not do variable substitution on $HOME. If you want shell processing then either use the shell form or execute a shell directly, for example: CMD [ "sh", "-c", "echo $HOME" ]. When using the exec form and executing a shell directly, as in the case for the shell form, it is the shell that is doing the environment variable expansion, not docker.
11
10
 
12
11
  # 結論
13
12
  私の試した範囲では、シェルを使用しない方法は見つけられませんでした。(環境変数の仕様としてはごく自然なことですが^^;)