简体   繁体   English

如何将命令行参数传递给docker-compose run?

[英]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. 我正在尝试将参数传递给docker-compose运行的基础命令,但是我不确定该怎么做。

This is what my non-docker command looked like: 这是我的非docker命令的样子:

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

Which passes --verbose --match="matching test name" to the test runner. --verbose --match="matching test name"传递给测试运行程序。

Now I want to run my tests in docker but I can't get this to work: 现在我想在docker中运行测试,但无法正常工作:

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

Is this possible or how should I go about this? 这可能吗,或者我应该怎么做?

docker-compose run will interpret -- --verbose --match="matching test name" as the command and arguments -- --verbose --match="matching test name" docker-compose run-- --verbose --match="matching test name"为命令和参数

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 您应该将命令和所有参数放在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 docker-compose用于简化不使事情复杂化,为此,您可以使用以下命令在docker-compose.yml文件中永久定义它

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何运行两个命令作为单个 docker-compose“命令”的一部分? - How do I run two commands as part of a single docker-compose "command"? 如何在.sh文件中运行“ docker-compose up”命令? - How to run “docker-compose up” command in .sh file? 使$ docker为docker-compose命令 - Make $ docker compose a command for docker-compose 如何在复制的 docker-compose 服务的所有容器上运行 shell 命令? - How to run a shell command on all containers of a replicated docker-compose service? 如何将命令行 arguments 传递给使用打开命令运行的程序? - how to pass command-line arguments to a program run with the open command? 如何在 docker-compose 卷中使用 bash 命令命令? - How can use bash command command in docker-compose volume? 如何为此命令创建别名,将 docker-compose logs -f 管道化为 less? - How can I make an alias for this command piping docker-compose logs -f into less? 如何在Bash中将变量设置为docker-compose restart命令的输出? - How to set a variable to the output of a `docker-compose restart` command in Bash? 如何在 Docker-compose bash 脚本命令上转义美元符号 - How to escape dollar sign on Docker-compose bash script command 使用单个命令行Shell脚本启动多个Docker容器(无需docker-compose) - start multiple docker containers with a single command line shell script (without docker-compose)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM