Quick answer
On a system Docker daemon running as root without user namespace remapping, PUID should match the host user ID the container process should write as, and PGID should match the host group ID the container process should write as. Rootless Docker and userns-remap translate those container IDs, so matching the visible numbers is not enough in those modes. UMASK controls default permissions for newly created files and directories when the image supports it.
If files arrive as 644 and another service cannot edit them, the creating process probably used a mask like 022. Use the Umask Calculator to compare 022, 002, 027, and 077 before changing a container environment.