我的 Makefile 中有一条规则。在此规则中,我需要操作一些 docker 特定的东西,因此我需要以可移植的方式获取容器的 id。另外,我正在使用 Docker Compose。这是我所拥有的不起作用的东西。
a-rule: some deps
$(shell uuid="$(docker-compose ps -q myService)" docker cp "$$uuid":/a/b/c .)
Run Code Online (Sandbox Code Playgroud)
我没有收到任何错误或输出,但没有成功执行。
我的目标是获取运行 myService 的容器的 uuid,然后使用该 uuid 将文件从容器复制到我的 docker 主机。
编辑:以下有效,但我仍然想知道是否可以进行内联变量设置
uuid=$(shell docker-compose ps -q myService)
a-rule: some deps
docker cp "$(uuid)":/a/b/c .
Run Code Online (Sandbox Code Playgroud)