0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DevContainerのセットアップでコンテナを起動できない場合の対処法

0
Posted at

背景

Claude CodeをDockerコンテナ内で利用する環境を構築していました。
その際に、開発環境として使うDockerコンテナをVS Codeからシームレスに操作できるよう、VS CodeでDevContainer拡張をインストールしていました。

しかし「コンテナーで開く」をクリックしてVS CodeからDockerコンテナに接続しようとしたタイミングで以下のエラーが出てきました。

最初にすべてのワークスペースフォルダーを含むフォルダーにワークスペースを保存する必要があります。

image.png

対処

コンテナにマウントしたいフォルダ(作業フォルダ)を開くこと

VS Codeの「ファイル > フォルダーを開く」から、"example" フォルダを開きました。

結果として、Dev Containerのコンソールが表示されました。
画面右下にある「コンテナーで再度開く」をクリックします。
image.png

devcontainer.jsonに記載したコンテナの起動が開始されました。
image.png

「開発コンテナー」という表示になり、VS CodeからDockerコンテナをシームレスに操作できるようになりました。
image.png

まとめ

VS CodeのDev Containerが「現在開いているフォルダー直下にある.devcontainerファイル」を探すため、.devcontainerを保存しているフォルダを開かなければいけなかった。

ここで選択したローカルのフォルダが、コンテナ側のフォルダにマウントされることとなる、と思い出せば選択しやすいかもしれない。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?