i trying to pass user group ID from my Linux environment to Dockerfile throught docker-compose. I know about about "args" in docker-compose.yml, but i need to find method for getting group id by executing shell commang "getent group mygroup | cut -d: -f3". This is a mandatory requirement, because then the container will be distributed in different environments where the name of the group is known, and the id will be different.
Here is what i talking about:
version: '3.3'
services:
...
php:
build:
context: './php-fpm'
args:
- GROUP_ID=<HERE I NEED TO GET SHELL COMMAND RESULTS>
container_name: php-fpm
...
Is any methods to do that?
Is something like this what you're after
$groupid = getent group mygroup | cut -d: -f3
docker-compose up --build --build-arg GROUP_ID=$groupid
or are you hoping to have the groupid command in the docker-compose script
Not exactly what you asked for.
You could set an environment variable before running your wrapper script. e.g.
export GROUP_ID=`getent group mygroup | cut -d: -f3`
run wrapper script to call your docker-compose file
Then you can retrieve the GROUP_ID inside your docker-compose file:
args:
- GROUP_ID=${GROUP_ID}
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