Home›Claude / Claude Code›【検証してみた】devcontainerでClaude Codeの会話履歴は本当に消えないのか?+全プロジェクトへ自動適用する方法

【検証してみた】devcontainerでClaude Codeの会話履歴は本当に消えないのか?+全プロジェクトへ自動適用する方法This article verifies whether Claude Code conversation history truly persists…

元記事を読むRead original articleqiita.com(新しいタブで開きます)(opens in a new tab)
AI2 点サマリSummary highlight
  • devcontainer環境でClaude Codeの会話履歴が永続化されるかを実際に検証し、全プロジェクトへ自動適用する設定方法をまとめた記事。
  • 履歴管理の信頼性を確認したい開発者に役立つ実践的な内容。

This article verifies whether Claude Code conversation history truly persists inside a devcontainer environment and explains how to automatically apply the setup across all projects, offering practical guidance for developers who rely on history continuity.

本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (qiita.com) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (qiita.com).

要約と収集メタデータに基づく AI 解説。元記事全文の転載・翻訳ではありません。AI explainer based on the summaries and collected metadata, not a copy or translation of the full source article.

devcontainerでClaude Codeを使う際、コンテナのリビルドによって認証情報と会話履歴が消える問題を取り上げ、マウント設定が実際に有効かを検証している。さらに、新しいプロジェクトでコンテナをreopenした時点から、同じ設定を自動適用する方法が示されている。

devcontainer

検証環境は、WSL2上のDockerとVS Code Dev Containers拡張の組み合わせだ。devcontainer.jsonでは、イメージとして「mcr.microsoft.com/devcontainers/dotnet:1-10.0-noble」を指定し、workspaceMountによってローカルのワークスペースをコンテナ内の「/code/blzrapp」へbindしている。consistencyにはcachedが設定されている。

Claude Code設定

Claude Codeには「ghcr.io/anthropics/devcontainer-features/claude-code:1.0」を使用する。あわせて、ローカル環境の「${localEnv:HOME}/.claude」をコンテナ内の「/home/vscode/.claude」へ、「${localEnv:HOME}/.claude.json」を「/home/vscode/.claude.json」へ、それぞれbindする構成だ。認証情報と会話履歴に関係するこれらの場所を、コンテナ内だけに閉じない設定となっている。

コンテナ内確認

設定ファイルへ記述しただけではなく、コンテナ内部からマウント状態も確認している。確認結果では、「/home/vscode/.claude」と「/home/vscode/.claude.json」の双方に対し、「/dev/sdd」がext4としてマウントされ、rwで認識されていることが表示された。これにより、指定した2つのパスにマウント設定が反映されていることを確かめている。

全プロジェクト適用

検証では、個別のプロジェクトだけでなく、新しいプロジェクトをコンテナでreopenした時点から設定を自動適用できるかも対象としている。会話履歴の継続性を確保するため、devcontainer.jsonの記述と、コンテナ内での実際のマウント確認を分けて扱う点が重要となる。

Claude Code conversation history

Using Claude Code in a devcontainer can cause authentication information and conversation history to disappear whenever the container is rebuilt. The article tests whether bind-mount settings prevent that loss and examines whether the same setup can be applied automatically when reopening a container for a new project.

The goal is to distinguish between merely adding the configuration and confirming that it is active inside the container.

devcontainer.json settings

The configuration is added to devcontainer.json. It uses the image mcr.microsoft.com/devcontainers/dotnet:1-10.0-noble and bind-mounts the local workspace to /code/blzrapp with cached consistency.

Claude Code is included through ghcr.io/anthropics/devcontainer-features/claude-code:1.0. Two additional bind mounts connect Claude Code data on the host with locations inside the container. ${localEnv:HOME}/.claude is mounted at /home/vscode/.claude, while ${localEnv:HOME}/.claude.json is mounted at /home/vscode/.claude.json. Both use cached consistency.

These mounts cover the directory and JSON file used for the authentication information and conversation history addressed by the test.

Docker and VS Code

The test environment consists of Docker running on WSL2 together with the VS Code Dev Containers extension. Rather than assuming the settings work because they appear in devcontainer.json, the verification is performed from within the running container.

The reported mount information shows /dev/sdd mounted on both /home/vscode/.claude and /home/vscode/.claude.json. In each case, the filesystem is identified as ext4 and the mount options include rw, indicating read-write access.

Automatically apply the setup

The article also addresses applying this configuration automatically when a container is reopened for a new project. Its practical focus is continuity across projects: the mount setup is intended to preserve Claude Code authentication information and conversation history through container rebuilds while making the same arrangement available when working with newly opened project containers.

ポコとTECHガイドPoko & TECH Guide

ポコと当サイトのTECHガイドが、記事の要約と収集した情報から読みどころを語るAI生成の対話です。Poko and TECH Dashboard's own TECH Guide discuss the article's highlights in an AI-generated conversation based on its summary and collected source details.

  1. ポコPokoリビルドするたびに認証情報と会話履歴が消えるの? これって大きいこと?Authentication and chat history can disappear after every rebuild? Is that a big deal?
  2. TECHガイドTECH Guideこの記事では、それを困りごととして扱い、マウント設定が実際に効いているかコンテナ内から確認しているよ。The article treats that as a real problem and checks from inside the container whether the mount settings are actually working.
  3. ポコPokoその「bind mount」って、どういう仕組み?What exactly is a bind mount?
  4. TECHガイドTECH Guideホスト側のファイルやフォルダを、コンテナ内の場所につないで使う仕組みだよ。今回は.claudeなどをつないでいるね。It connects host files or folders to locations inside the container. Here, it links items such as .claude.
  5. ポコPokoぼくなら全プロジェクトに自動で設定して、前の会話を引き継げるようにしたいな。I’d want to apply it automatically to every project so my previous conversations can carry over.
  6. TECHガイドTECH Guide試した環境はWSL2上のDockerとVS Code Dev Containers拡張だよ。別の環境でも同じとは、この記事だけでは断定できないね。The tested setup uses Docker on WSL2 with the VS Code Dev Containers extension. The article doesn’t establish that every other environment behaves the same way.
記事情報・収集記録Article details & collection record
出典Source
Qiita VSCodeコミュニティCommunity
公開日時 (JST)Published (JST)
収集日時 (JST)Collected (JST)
配信形式Format
ブログBlog
原文言語Source language
JA
重要度の位置づけImportance in this lane
MediumMedium priority(Claude / Claude Code 174件中、同等以上 138件)(138 of 174 Claude / Claude Code entries are equal or higher)
出典の平均重要度(掲載直近 30 件・最大 30 件)Source average (last 30 listed, up to 30)
1.7 / 31=情報 · 2=中 · 3=高1=Info · 2=Medium · 3=High
情報の寿命Half-life
中期 (チュートリアル)Medium-term (tutorial)

🧡Claude / Claude Code の他の記事More from Claude / Claude Codeもっと見る →View more →

ページ上部へScroll to top