{"record":{"id":"f8c6e781729a4112","repo":"testcontainers/testcontainers-java","slug":"error-running-local-docker-compose-command-cmd","errorCode":null,"errorMessage":"Error running local Docker Compose command: ${cmd}","messagePattern":"Error running local Docker Compose command: (.+?)","errorType":"exception","errorClass":"ContainerLaunchException","httpStatus":null,"severity":"critical","filePath":"core/src/main/java/org/testcontainers/containers/LocalDockerCompose.java","lineNumber":124,"sourceCode":"            new ProcessExecutor()\n                .command(command)\n                .redirectOutput(Slf4jStream.of(logger()).asInfo())\n                .redirectError(Slf4jStream.of(logger()).asInfo()) // docker-compose will log pull information to stderr\n                .environment(environment)\n                .directory(pwd)\n                .exitValueNormal()\n                .executeNoTimeout();\n\n            logger().info(\"Docker Compose has finished running\");\n        } catch (InvalidExitValueException e) {\n            throw new ContainerLaunchException(\n                \"Local Docker Compose exited abnormally with code \" +\n                e.getExitValue() +\n                \" whilst running command: \" +\n                cmd\n            );\n        } catch (Exception e) {\n            throw new ContainerLaunchException(\"Error running local Docker Compose command: \" + cmd, e);\n        }\n    }\n\n    /**\n     * @return a logger\n     */\n    private Logger logger() {\n        return DockerLoggerFactory.getLogger(this.composeExecutable);\n    }\n}\n","sourceCodeStart":106,"sourceCodeEnd":135,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/containers/LocalDockerCompose.java#L106-L135","documentation":"LocalDockerCompose invokes the local `docker-compose` binary via an external process. If the process fails in any way other than a detected non-zero exit code, Testcontainers wraps the failure in a ContainerLaunchException carrying the exact command that was run. The original exception is attached as the cause.","triggerScenarios":"invoke() runs `docker-compose ... up` as a shell command and any Exception other than the specific ShutdownException for abnormal exit codes (e.g. docker-compose binary missing, Docker daemon not reachable, compose file invalid in a way the CLI crashes on) triggers this throw.","commonSituations":"Docker daemon not running, `docker-compose`/`docker compose` not installed or not on PATH, malformed compose file passed to LocalDockerComposeCampaign, environment misconfiguration on CI agents.","solutions":["Run the same `cmd` shown in the message manually to see the underlying error (inspect the cause exception).","Verify Docker is running (`docker ps`) and the compose binary is on PATH (`which docker-compose`).","Check the compose file syntax with `docker-compose -f <file> config`.","On CI, ensure the Docker socket is mounted and permissions allow access."],"exampleFix":"// before: relying on a broken environment\nnew LocalDockerComposeCampaign(new DockerComposeContainer<>(new File(\"docker-compose.yml\"))).start();\n// after: pre-check the environment before starting\nnew ProcessBuilder(\"docker-compose\", \"version\").start().waitFor(); // fails fast with a clear message if binary missing","handlingStrategy":"try-catch","validationCode":"new ProcessBuilder(\"docker-compose\", \"version\").inheritIO().start().waitFor() == 0; // also check `docker info`","typeGuard":null,"tryCatchPattern":"try { composeContainer.start(); } catch (ContainerLaunchException e) { logger.error(\"docker-compose failed: {}\", e.getCause(), e); throw new EnvironmentPreconditionException(e); }","preventionTips":["Assert Docker and docker-compose availability in test setup before any container starts.","Pin docker-compose versions in CI images.","Run `docker-compose -f file config` as a build-time lint step."],"tags":["docker-compose","container-launch","process-execution"],"backgroundTag":"command-not-found","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}