I want to execute a perl script inside a docker container as root (SUDO on the host), and get the real user id inside the perl script.
For eg., below execution should enable myscript.pl to get the real userId (mat in this case), without having to pass it explicitly as an additional parameter to myscript.pl.. (The script inside the container when invoked from the host should find the real user invoking the script)
[mat@dev01-nrg02 ~]$ sudo docker exec -it MY_API_LAYER myscript.pl
Setting as docker environment variables during start-up of the container is ruled out, since
- The script would be executed by any user, and i need to get that user's real Id.
- The docker container is started up using an Init service...so this would mean technically also there is no possibility to set any user detail...
Also..
I do not want to trouble the users of the script by having them to pass their userId (which could appear as redundant, also they could pass any Id, if such an option is provided..)
Please let me know if anyone has had such a problem and resolved it?