# docker compose run Command Reference

> Reference for docker compose run in CI: run a one-off command in a service container with --rm, -e, and --no-deps, for tests and migrations in pipelines.

Source: https://latchkey.dev/learn/command-reference/docker-compose-run-command-reference  
Updated: 2026-06-26

Run a one-off command against a service.

docker compose run starts a new container for a service and runs a command in it, separate from the long-running service started by up. In CI it executes test suites, migrations, or scripts using the service image and its dependencies.

## Common flags

- `--rm` - remove the container after the command exits
- `-e KEY=value` - set an environment variable for the run
- `--no-deps` - do not start linked services
- `-T` - disable pseudo-TTY allocation (use in CI)
- `-w, --workdir` - working directory inside the container

## Example

```shell
docker compose run --rm -T -e CI=true app npm run test
```

## In CI

Pass -T to disable the pseudo-TTY (the "the input device is not a TTY" fix for compose) and --rm so the throwaway container is cleaned up. Use --no-deps when the dependencies are already running from a prior compose up to avoid starting duplicates.

## FAQ

### docker compose run Command Reference?

docker compose run starts a new container for a service and runs a command in it, separate from the long-running service started by up. In CI it executes test suites, migrations, or scripts using the service image and its dependencies.

### In CI?

Pass -T to disable the pseudo-TTY (the "the input device is not a TTY" fix for compose) and --rm so the throwaway container is cleaned up. Use --no-deps when the dependencies are already running from a prior compose up to avoid starting duplicates.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
