docker - 为 docker-compose 导出 makefile 中的当前用户 ID
问题描述
我试图将当前用户 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?
解决方案
这是我的解决方案
#!/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
推荐阅读
- mysql - 复合索引是否也适用于第二个字段的查询?
- java - Scala vs Java toUpperCase/toLowerCase
- amazon-web-services - 如何确定 S3 存储桶 URL?什么决定了 FQDN?
- javascript - 一次播放一个音频 Nextjs
- python - 如何在for循环中将字符串与python中的列表连接起来
- javascript - 如何配置网站 (Php) 以运行 Cordova Camera 插件代码
- c# - 异常弹出窗口似乎放大了
- javascript - 输入验证后弹出并提交Javascript
- java - 为什么有时我需要在 `package` 之前运行 `build`?
- tinymce - 在 TinyMCE 中隐藏源输入字段或更改显示的 url