I would like to run a docker entrypoint that creates a new user, switches to that user and destroys root shell so it cannot be exited back into
In the command line this works
$ useradd -s /bin/bash toby
$ exec su toby
If I exit from it the container stops which is as expected.
But, when I put this in a script the root shell is still there and can be exited into
--- NOTE ---
Sorry, I got things mixed up.
This actually works as intended when I use the script as ENTRYPOINT
I didn't put username in the dockerfile as I want it be assigned on docker run as in
docker run -e USER=$USER myimage