Is it possible to send user:group as a command line parameter ?
dbjpanda opened this issue · 1 comments
dbjpanda commented
My entrypoint is something like below. So how can I pass the user:group value to fixuid instead from docker-compose.yml or docker run ? Why I want like this because I am trying to get the user id from a mounted file in entrypoint script.
HOST_CURRENT_USER_ID=$(stat -c "%u" /var/www/.gitkeep)
if [ $HOST_CURRENT_USER_ID -ne 0 ]; then
eval $( fixuid user:group)
fi
caleblloyd commented
Option 1:
Evaluate the mounted path outside the container in docker run
:
docker run -u "${stat -c "%u" /path/to/.gitkeep}:${stat -c "%u" /path/to/.gitkeep}" --entrypoint "fixuid" <image>
Option 2:
Install sudo
in your container and sudo in entrypoint
#!/bin/sh
# this is the entrypoint
echo "root ALL=(ALL:ALL) ALL" >> /etc/sudoers
sudo -E -u "#$(stat -c '%u' /var/www/.gitkeep)" -g "#$(stat -c '%g' /var/www/.gitkeep)" fixuid "$@"