LoginSignup
1
1

More than 3 years have passed since last update.

【Docker】exec形式とshell形式

Posted at

DockerのENTRYPOINTとかCMD書くときの形式ってどうすればいいのか

Dockerfileのリファレンスではexec形式が推奨されている。
shell形式とexec形式の違い

シェル形式

/bin/sh -c "コマンド 引数1 引数2"として実行される

shell形式
RUN bundle exec rails assets:precompile

exec形式

コマンドを直接(シェルを通さず)実行コマンドや引数を囲むときのシングルクォートは使えない

exec形式
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]

# シェルで実行したい場合には(パイプ等が使用できる)
CMD ["ash", "-c", "bundle exec rails server -b 0.0.0.0"]
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1