docker compose exec -w /app web npm test

Category: Docker

docker compose exec -w /app web npm test

Execute a command in a specific workdir

-w sets the working directory inside the container before running the command, here running tests from /app. Avoids chaining cd into the command itself. Equivalent to docker exec --workdir.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.