kotto5 / Inception

Construct Wordpress service with three container (nginx, wordpress, mariadb)
0 stars 0 forks source link

コンテナは無限ループするコマンドを実行してはならない #10

Closed kotto5 closed 10 months ago

kotto5 commented 10 months ago

Your containers musn’t be started with a command running an infinite loop. Thus, this also applies to any command used as entrypoint, or used in entrypoint scripts. The following are a few prohibited hacky patches: tail -f, bash, sleep infinity, while true.

わざわざなんで? サービスが実行できないということになるので、課題要件的に必然的にOUTだと思うが、明示的に言われている理由がわからない

kotto5 commented 10 months ago

起動されて何もしないコンテナの需要

Docker コンテナを運用する際、仮想化された環境内で動作するコンテナプロセスを最小限に抑えることで無駄なサーバーリソースの消費を抑え、コストダウンにつなげることができます。 しかし、場合によっては何もしないコンテナを起動しておき、そのままにしたいというケースがあります。 具体的には AWS ECS 環境や CKE 、Kubernetes 環境でコンテナを立ち上げ、アタッチ ( 接続 ) して運用作業を行いたい、といった場合です。 そんなときに役立つのが「永遠に終了せず何もしない」コンテナです。

kotto5 commented 10 months ago

利用用途は分かった。普通に、サービスがまだ立ち上げられない状況とか、Dockerfile をまず作成しようとする段階で、それでもコンテナに入るためにはフォアグラウンドで動いているプロセスが必要で、sleep infinity は普通に使った。