Can't create directory 'data': permission denied

OS: ubuntu20.04

USER app
RUN ls -l …/
RUN mkdir data

root root app
can’t create directory ‘data’: permission denied

ps: The same Dockerfile can build successfully on windows 10 environment

Is anybody know why windows 10 works but ubuntu20.04 fails?
Thanks a lot ~~

You are apparently running as user app which likely has no privilege to create that folder.
You might need to temporarily change to a privileged user for that operation.
Windows and Linux have different mechanics to deal with privileges. Originally Docker was though for Linux. That’s why you have Docker Engine on Linux and Docker Desktop on Windows and Mac.
You can see Docker Desktop as a package that wraps Docker Engine to make it work on those OSes.