Skip to content

Feature/mount-config-dir-into-container #876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

braun-viathan
Copy link

@braun-viathan braun-viathan commented May 9, 2025

Fixes #789

What?

This PR enhances run_in_container.sh by optionally mounting the user's local .codex configuration directory into the Docker container. This allows configuration and session persistence between container restarts.

Key Changes:

  • Adds an optional --config flag.
  • Default configuration path: $HOME/.codex if --config not provided.
  • Updates usage examples and documentation.

Why?

  • Currently, users lose Codex CLI configurations (approval modes, presets, logs) between container runs, as no persistent storage is provided. This change aligns Linux Docker behavior with other environments and improves the overall developer experience.

  • Until the rust implementation will run stable with sandbox features for all OS, this improves the general experience for linux users with the containerized TS version until rust is ready.

How?

  • Implemented optional bind mount based on the existence of the provided config directory.
  • Ensured backward compatibility: no breaking changes for existing users who do not provide a config path.

Manual Testing Steps:

  1. Build the container:

    ./codex-cli/scripts/build_container.sh
  2. Execute Codex CLI with config mounted:

    ./codex-cli/scripts/run_in_container.sh \
      --work-dir "$(pwd)" \
      --config ~/.codex \
      "COMMAND"
      
      ./codex-cli/scripts/run_in_container.sh \
      "COMMAND"
  3. Confirm that the mounted config is active (e.g., correct approval mode loaded).

Tested locally with success.

Checklist:

  • Implementation

  • Local testing: pnpm test && pnpm lint && pnpm typecheck -> Passed: log

  • Manual testing done:

    • ~/.codex/config.yml contains: model: o4-mini & approvalMode: suggest, as you can see in the screenshot below the config is mounted and used correctly in the local conatiner run.

      image

  • Examples updated in run_in_container.sh

Open Question:

  • Awaiting feedback if further unit or e2e are needed either to run locally or in ci before merging this one.

@braun-viathan braun-viathan marked this pull request as ready for review May 9, 2025 13:57
@braun-viathan braun-viathan force-pushed the feature/mount-config-dir-into-container branch 2 times, most recently from 71340c3 to 4abe92a Compare May 12, 2025 16:27
@braun-viathan
Copy link
Author

braun-viathan commented May 12, 2025

Friendly ping @fouad-openai 😊

It’s been a few days and local tests are looking good.
This PR only adds an optional --config mount to run_in_container.sh so Linux users can persist their .codex settings (parity with macOS). No other logic changed.

When you have a moment, could you let me know if anything else is needed?
Thanks a lot!

@braun-viathan braun-viathan force-pushed the feature/mount-config-dir-into-container branch 2 times, most recently from f80c199 to 6ee04c6 Compare May 20, 2025 17:35
Enables users to persist Codex CLI configuration
across container runs by optionally mounting their
local `.codex` directory using the `--config` parameter.

Fixes openai#789
Updated examples in the script to reflect
the new `--config` flag usage,
improving clarity and user understanding.
@braun-viathan braun-viathan force-pushed the feature/mount-config-dir-into-container branch from 6ee04c6 to fbcba98 Compare May 25, 2025 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(run_in_container): optionally mount ~/.codex so Linux users keep configs & logs
1 participant