我正在尝试将当前用户ID传递到 docker-compose.yml
中。
在 docker-compose.yml
中的写法如下:
version: '3.4'
services:
app:
build:
context: ./
target: "php-${APP_ENV}"
user: "${CURRENT_UID}"
我写了一个 Makefile 替代 CURRENT_UID=$(id -u):$(id -g) docker-compose up -d
#!/usr/bin/make
SHELL = /bin/sh
up:
export CURRENT_UID=$(id -u):$(id -g)
docker-compose up -d
当我运行make up
时,CURRENT_UID
仍然为空。
在Makefile中是否有可能导出uid?
$(VARIABLE)
是 Make 扩展语法。你需要使用$$
来插入美元符号,或者使用 GNU make 的$(shell command ...)
扩展。 - David Maze$(shell ...)
。这是不必要的,只会造成混乱。 - MadScientist