PhpStorm Dev Containers: shared .idea settings embed machine-specific paths
0 reputation · 03 Apr 2022, 15:56 UTC
0 reputation · 03 Apr 2022, 15:56 UTC
A team wants a repeatable PhpStorm development environment using Dev Containers, with inspections, code style, and run configurations traveling alongside the container definition.
Committing the .idea directory looks like the obvious way to share that configuration. However, project settings can embed absolute paths, interpreter locations, and user-specific state, which may break on other machines or create merge conflicts. Native Dev Containers support also depends on the installed PhpStorm build.
Should .idea be committed for a Dev Containers workflow, or should teams rely on per-user settings and Settings Sync? Which .idea subdirectories are safe to share without exposing machine-specific paths? What approach handles PhpStorm build differences when sharing container-based project configuration?
35775 reputation · 04 Apr 2022, 03:00 UTC
Do not commit the entire .idea directory. Commit only a curated subset—typically codeStyles/, inspectionProfiles/, dictionaries/, fileTypes/, and copyright/, plus runConfigurations/ only after every absolute path is replaced with $PROJECT_DIR$ or a container path such as /workspace. Never commit workspace.xml, tasks.xml, usageStatistics.xml, or files that store local interpreters, deployment servers, or window state. Settings Sync cannot replace this because it synchronizes per-user preferences, not project-level .idea contents.
.idea mixes team-shared inspection and style settings with per-user workspace state. PhpStorm writes absolute host paths into workspace.xml and tasks.xml, and run configurations may embed local SDK paths, server URLs, or working directories. Inside a Dev Container the project is typically mounted at a stable path such as /workspace, so container-relative references are portable across team members; host absolute paths are not.
Assumption: your team uses a PhpStorm build that supports Dev Containers and mounts the project at a consistent container path. This has not been independently verified for your specific build, so treat the safe-subdirectory list as a starting point, not a guarantee.
grep -R "/Users" .idea
grep -R "/home/" .idea
git status --porcelain .idea
The grep commands are read-only searches for absolute host paths in .idea XML files. The git command shows whether PhpStorm added local-only entries after opening the project.
Do your shared run configurations reference host PHP interpreters, deployment servers, or host-only working directories? If yes, runConfigurations/ is not safe to share even after path substitution, and the team should instead document container-side configuration rather than commit it.
Use comments to ask for clarification. Post a solution as an answer.
6,300 reputation · 04 Apr 2022, 00:04 UTC
Marking a run configuration as shared in PhpStorm moves its XML from workspace.xml (user-local) into a dedicated file under .idea/runConfigurations/. This does not sanitize the content—interpreter references, Docker container settings, path mappings, and environment variables remain exactly as authored. If those values contain host-specific paths or credentials, the shared file will still break on another machine.
git status immediately after the first project load..idea/ indicate user-state leakage that must be added to .gitignore or fixed in the shared configuration.This test catches both absolute-path leftovers and files PhpStorm rewrites on open (such as workspace.xml or tasks.xml) before they pollute the shared history.