Problem
openemr-cmd's automatic container detection picks the wrong container when multiple development stacks are running side-by-side (e.g. one per git worktree).
The two filters in utilities/openemr-cmd/openemr-cmd:
INSANE_DEV_DOCKER="openemr-8-4[_\-]1"
EASY_DEV_DOCKER="openemr[_\-]1"
are passed to docker ps --filter "name=...", which Docker treats as a regex anywhere in the name, not anchored to the end. With several worktree stacks running, that regex matches every auxiliary container whose name happens to end in -1 — openemr-<wt>-phpmyadmin-1, openemr-<wt>-mysql-1, openemr-<wt>-selenium-1, etc. — in addition to the real openemr-<wt>-openemr-1. The script then takes head -n 1, so the chosen container is essentially arbitrary (in practice, often phpmyadmin or another helper).
Symptom
Running any devtools-backed subcommand (e.g. openemr-cmd drid) bombs out with:
OCI runtime exec failed: exec failed: unable to start container process:
exec: "/root/devtools": stat /root/devtools: no such file or directory
That's the chosen container reporting that /root/devtools doesn't live there — it's not the openemr container, it's an auxiliary one. The -d <container> flag works around it, but the auto-detection should be reliable.
Reproduction
- Bring up the easy dev stack in two or more worktrees (different
COMPOSE_PROJECT_NAME).
- From any shell, run
openemr-cmd drid (or openemr-cmd shell, openemr-cmd php-log, etc. — anything that uses run_devtools_in_docker).
- Observe the exec failure above when the regex picks a non-openemr container.
Why now
This used to be a non-issue because most setups had at most one easy-dev stack running. Worktree-based workflows (one stack per branch under review) make the collision routine — every additional stack contributes ~6 more containers ending in -1, and the auxiliary ones sort first under common naming.
Problem
openemr-cmd's automatic container detection picks the wrong container when multiple development stacks are running side-by-side (e.g. one per git worktree).The two filters in
utilities/openemr-cmd/openemr-cmd:are passed to
docker ps --filter "name=...", which Docker treats as a regex anywhere in the name, not anchored to the end. With several worktree stacks running, that regex matches every auxiliary container whose name happens to end in-1—openemr-<wt>-phpmyadmin-1,openemr-<wt>-mysql-1,openemr-<wt>-selenium-1, etc. — in addition to the realopenemr-<wt>-openemr-1. The script then takeshead -n 1, so the chosen container is essentially arbitrary (in practice, often phpmyadmin or another helper).Symptom
Running any devtools-backed subcommand (e.g.
openemr-cmd drid) bombs out with:That's the chosen container reporting that
/root/devtoolsdoesn't live there — it's not the openemr container, it's an auxiliary one. The-d <container>flag works around it, but the auto-detection should be reliable.Reproduction
COMPOSE_PROJECT_NAME).openemr-cmd drid(oropenemr-cmd shell,openemr-cmd php-log, etc. — anything that usesrun_devtools_in_docker).Why now
This used to be a non-issue because most setups had at most one easy-dev stack running. Worktree-based workflows (one stack per branch under review) make the collision routine — every additional stack contributes ~6 more containers ending in
-1, and the auxiliary ones sort first under common naming.