0
0

More than 1 year has passed since last update.

vscode + docker/docker-compose の作業をするときに最初にやること

Posted at

vscode では docker/docker-compose での開発作業が楽にできる。
基本的には

  • Remote Development 拡張をインストールする
  • 適当に docker-compose関連のファイル群を追加する
  • 開発コンテナー構成ファイルを追加する
  • コンテナを再度開く

のような手順でdocker-compose.ymlに書いたコンテナが一斉に起動して使用可能になる…はずなのだが、デフォルト設定を使ってnginxとかでweb serverを実行しようとするとそのコンテナは起動しないかnginxが起動できない、とか言う結果となる。

以前にも同じ目にあって「ああ、これは罠だ」と思ったはずなのだけど1年ぶりとかに別の作業をし始めてから4時間ほど悩んでしまった。

.devcontainer/docker-compose.yml

    # Overrides default command so things don't shut down after the process ends.
    command: /bin/sh -c "while sleep 1000; do :; done"

この記述を抹消する。
コメントに書かれている通り、このコマンドは「実行が終了してしまうようなコンテナを実行し続けたい場合に実行の終了を阻止する」ために実行されなければならないが、 nginxとかはデフォルトでコンテナを実行し続けようとするはずなのでまったく無駄というか邪魔なので、消してしまって問題ない。

0
0
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
0
0