如何使用Makefile正确运行docker [英] How to properly run docker with Makefile

查看:78
本文介绍了如何使用Makefile正确运行docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个制作文件:

APP_NAME=sgy-core-bdd/codeception

build: ## Build the container
    docker build -t $(APP_NAME) .

run:
    docker run --entrypoint /bin/bash -i -t -v $(pwd):/app $(APP_NAME)

当我执行 make run 时,出现此错误

when i do make run i get this error

make: *** No rule to make target `/app', needed by `run'.  Stop.

如何解决此错误

推荐答案

食谱行必须使用真实的TAB字符缩进.在您的示例中,很可能该行没有用TAB缩进.

Recipe lines must be indented with a real TAB character. In your example, it's likely that line is not indented with a TAB.

这意味着这一行:

docker run --entrypoint /bin/bash -i -t -v $(pwd):/app $(APP_NAME)

被视为制定规则,而不是配方,等同于写作:

is treated as a make rule, not a recipe, which is the equivalent of writing:

docker: /app $(APP_NAME)
run: /app $(APP_NAME)
--entrypoint: /app $(APP_NAME)
/bin/bash: /app $(APP_NAME)
-i: /app $(APP_NAME)
-t: /app $(APP_NAME)
-v: /app $(APP_NAME)
$(pwd): /app $(APP_NAME)

因此,当您使用 make run 时,它想要构建先决条件/app $(APP_NAME).

So when you use make run, it wants to build the prerequisites /app and $(APP_NAME).

这篇关于如何使用Makefile正确运行docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆