Skip to content

feat(cli): Mount user config directory in container #857

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

Conversation

braun-viathan
Copy link

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

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.

Fixes: #789

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.

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 \
      "codex --version"
  3. Confirm that the mounted config is active (e.g., correct approval mode loaded).

Tested locally with success.
2025-05-08_00-50

Checklist:

  • Implementation
  • Manual testing done
  • Examples updated
  • Awaiting feedback if further documentation is needed in README.md.

Enables users to persist Codex CLI configuration
across container runs by optionally mounting their
local `.codex` directory using the `--config` parameter.

Fixes openai#789
@github-actions github-actions bot locked and limited conversation to collaborators May 8, 2025
@braun-viathan braun-viathan deleted the feature/mount-config-dir-clean branch May 8, 2025 15:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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