I have a docker image that runs on linux alpine. Sudo is not installed. I would like to build the image with a non-root user but I need to run a start script from CMD as root after the image is build.
I need to open the container in vscode and if the USER is root then all new files created inside the container environment (and mounted in a volume) will be owned by root and therefore needs sudo to modify from the host system.
If I change the USER to anything but root in the Dockerfile, then the start.sh script running in my parent image CMD cannot run.
I have tried a few things like:
- Dockerfile RUN is done as root and the start.sh script ends with: su . to change the user back to the non root. This has no effect on vscode ownership. I can then create new files from the terminal with the non root user, but I would rather be able to use vscode create new file (which is still owned by root)
- Override the CMD to run with sudo (but sudo not installed. And I do not want to install it)
CMD su root -c /start.sh
but I dont know the root password in the docker image, and I do not want to modify the root password
Any help with finding a way to run my start.sh script with root privileges without using sudo would be greatly appreciated.