Summary:
I am using python to start Nvidia docker containers to run ML tasks with my GPU. This seems to require the container to have root level privileges. To do this programmatically I have a python string assembler which makes the docker runtime string.
IE: sudo docker run --gpus All ...
Executed by: os.system(runString)
I have updated this string generator to include f"echo {SUDOPASS} | sudo -S..."
as a method of not requiring sudo every time a need for a docker container comes around. Some of my jobs run for hours with multiple containers in use.
Issue:
So my issue is that this approach just feels wrong. My code execution vulnerability alert is shrieking in my head. It feels so easy for someone to abuse this by adjusting the string generator or some other method. I would someday like to post this to git and not worry about my code being used to insert crap. As docker, python and linux are ubiquitous and I have seen others approach this issue in parts I was wondering if anyone might have some best practices advice?