Creating a custom user in a Dockerfile is a straightforward thing, but to rename an existing user from the base image is a hassle and has to be done right. But why bother, you may wonder. This is not required for you unless you are using Docker on Windows host sharing the host directory as volume mount.
On Windows with Docker Desktop (especially using WSL2 backend), file permissions are mapped based on UID/GIDs. The default first user in WSL2 is typically UID 1000. If you use UID 2000 inside the container, files created by the container will have owner UID 2000, which on the WSL2 host will appear as an unknown user (or a different user), leading to permission issues when you try to edit those files from the host. The better approach is to reuse UID 1000 cleanly by renaming the existing node user (which already has UID 1000) to your desired username, instead of deleting it or creating a new user with a different UID.
Reference Dockerfile for such occasions is below:
-- --
Reference Dockerfile for such occasions is below:
-- --