Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass command line arguments to docker-compose run?

I'm trying to pass arguments to the underlying command that docker-compose runs, but I'm not sure how to do it.

This is what my non-docker command looked like:

npm run test:watch -- --verbose --match="matching test name"

Which passes --verbose --match="matching test name" to the test runner.

Now I want to run my tests in docker but I can't get this to work:

docker-compose run test-service-name -- --verbose --match="matching test name"

Is this possible or how should I go about this?

like image 338
Christiaan Maks Avatar asked Oct 27 '25 06:10

Christiaan Maks


1 Answers

docker-compose run will interpret -- --verbose --match="matching test name" as the command and arguments

Usage:
    run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] [-l KEY=VALUE...]
        SERVICE [COMMAND] [ARGS...]

You should put the command and all the arguments in the cli

docker-compose run test-service-name npm run test:watch --verbose --match="matching test name"

docker-compose is used to simplify not to complicate things up, for this you can define it permanently in the docker-compose.yml file using command

command: npm run test:watch --verbose --match="matching test name"

source: https://docs.docker.com/compose/compose-file/#command

like image 67
Hernan Garcia Avatar answered Oct 28 '25 19:10

Hernan Garcia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!