Session does not persist across dev container rebuilds

Open 💬 7 comments Opened Feb 18, 2026 by jmml97

What version of the IDE extension are you using?

0.4.76

What subscription do you have?

Plus

Which IDE are you using?

VS Code

What platform is your computer?

Darwin jose-martin.local 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:07:05 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6020 arm64

What issue are you seeing?

Description

I use Visual Studio Code with the Remote Containers extension and typically work by connecting directly to a development container.

Problem

Each time the container is destroyed and recreated, I am required to log in again to ChatGPT in the Codex sidebar.

Impact

Since containers are frequently rebuilt during development, having to authenticate repeatedly becomes tedious and disrupts the workflow.

What steps can reproduce the bug?

  1. Open Visual Studio Code.
  2. Connect to a development container using the Remote Containers extension.
  3. Log in to ChatGPT in the Codex sidebar.
  4. Destroy and recreate the development container (for example, by rebuilding it).
  5. Reopen the container in Visual Studio Code.

You are required to log in to ChatGPT again in the Codex sidebar.

What is the expected behavior?

The authentication session should persist, and logging in again should not be necessary after the container is rebuilt.

Additional information

_No response_

View original on GitHub ↗

7 Comments

tomerh2001 · 4 months ago

+1

arditramaj1 · 4 months ago

+1

arditramaj1 · 4 months ago

Is this in plan to be added?

tomerh2001 · 4 months ago

@arditramaj1 I found a workaround for this. Mount the host .codex (usually in ~/.codex) directory into your dev container, and Codex state will persist across rebuilds, including the login session.

arditramaj1 · 4 months ago

I just fixed it right now. Thanks a lot for the reply.

jmml97 · 4 months ago
@arditramaj1 I found a workaround for this. Mount the host .codex (usually in ~/.codex) directory into your dev container, and Codex state will persist across rebuilds, including the login session.

This works as a workaround. Thanks!

arditramaj1 · 4 months ago

Another thing that might help you @tomerh2001 @jmml97. If you need to push it to github and other people on your team do not have that .codex directory the mount will fail if they do not have that directory in the host. If this is the case, then use initializeCommand hook from devContainer extension to create the folder like this:

"initializeCommand": "mkdir -p ${localEnv:HOME}/.codex",

and then the mount should be kinda like this:

"mounts": [
"source=${localEnv:HOME}/.codex,target=/home/{your-user}/.codex,type=bind,consistency=delegated"

],
"remoteUser": "your-user",

I hope this helps you!