[英]Makefile - append to command
I am writing a Makefile for my Docker app. 我正在为我的Docker应用程序编写Makefile。 I have
make start-image
, which starts the image with it's default command: 我有
make start-image
,它使用默认命令启动图像:
start-image:
docker run name
I would like to have another command make do_something
which would append the command that should be run within the docker container: 我想要另一个命令
make do_something
,它将附加应该在docker容器中运行的命令:
do_something:
docker run name command args
How can I use the start-image command to do that? 如何使用start-image命令执行此操作?
Use a variable to store the common part of the commands 使用变量存储命令的公共部分
RUNTOOL=docker run name
start-image:
${RUNTOOL}
do-something:
${RUNTOOL} command args
With this strategy, it is also possible to build the RUNTOOL variable out of smaller parts to accomodate for more complex tasks. 通过这种策略,还可以从较小的部分构建RUNTOOL变量,以适应更复杂的任务。
start-image:
docker run name $(ARGS)
do_something: ARGS=command args
do_something: start-image
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.