Skip to content

openemr-cmd: container auto-detection picks wrong container when multiple stacks run #688

Description

@kojiromike

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 -1openemr-<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

  1. Bring up the easy dev stack in two or more worktrees (different COMPOSE_PROJECT_NAME).
  2. From any shell, run openemr-cmd drid (or openemr-cmd shell, openemr-cmd php-log, etc. — anything that uses run_devtools_in_docker).
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions