3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker-composeでentrypointを指定するとDockerfileのCMDが無視されるよというお話

Posted at

タイトルの通りなんですけども、ちょっとハマったので書き残しておこうかなと思いました。
ってか、ドキュメントにガッツリ書いてあるんですけどね。読めよって話ですよね。。

Note: Setting entrypoint both overrides any default entrypoint set on the service’s image with the ENTRYPOINT Dockerfile instruction, and clears out any default command on the image - meaning that if there’s a CMD instruction in the Dockerfile, it is ignored.

google翻訳さん

注:entrypointを設定すると、ENTRYPOINT Dockerfile命令を使用してサービスのイメージに設定されているデフォルトのエントリポイントが上書きされ、イメージのデフォルトコマンドが消去されます。DockerfileにCMD命令がある場合は無視されます。

ハマったケース

DBの起動を待ってからWebサーバーを起動しようと思って dockerize を使ってたのですけども、このdockerizeのコマンドを docker-compose.yml の entrypoint に書いてた訳です。
コンテナに直截入って叩けば起動するし、docker-compose.ymlのcommandに書いても起動するし、なんなんだよーって思って調べたら公式の注意書きに書いてありました。。

まとめ

何か壁にぶち当たったら、まずは公式ドキュメント読みましょう。。

3
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?