在makefile中导出docker-compose的当前用户ID

问题描述 投票:0回答:1

我试图将当前用户ID传递给docker-compose.yml

它在docker-compose.yml中的样子

version: '3.4'

services:
    app:
        build:
            context: ./
            target: "php-${APP_ENV}"
        user: "${CURRENT_UID}"

而不是CURRENT_UID=$(id -u):$(id -g) docker-compose up -d我写了makefile

#!/usr/bin/make

SHELL = /bin/sh

up: 
    export CURRENT_UID=$(id -u):$(id -g)
    docker-compose up -d

但是当我运行CURRENT_UID时,make up仍然空着

makefile中是否有可能的导出uid?

docker makefile docker-compose
1个回答
0
投票

这是我的解决方案

#!/usr/bin/make

SHELL = /bin/sh

CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)

export CURRENT_UID
export CURRENT_GID

up: 

    docker-compose up -d
© www.soinside.com 2019 - 2024. All rights reserved.