I trying to pass the current user id into docker-compose.yml
How it looks in docker-compose.yml
version: '3.4'
services:
app:
build:
context: ./
target: "php-${APP_ENV}"
user: "${CURRENT_UID}"
Instead of CURRENT_UID=$(id -u):$(id -g) docker-compose up -d
I've wrote makefile
#!/usr/bin/make
SHELL = /bin/sh
up:
export CURRENT_UID=$(id -u):$(id -g)
docker-compose up -d
But CURRENT_UID
still empty when I run make up
Is there a possible export uid in makefile?
Here is my solution
#!/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
Another option is to use env
:
Makefile:
SHELL=/bin/bash
UID := $(shell id -u)
up:
env UID=${UID} docker-compose up -d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With