Error: EACCES When running a docker command

I encontered “Error: EACCES” while running the following Docker command.

docker run --rm -it --user $(id -u):$(id -g) --volume "$PWD:/app" dannyben/completely generate

However, the following Docker command succeed.

docker run --rm -it --user $(id -u):$(id -g) --volume "$PWD:/app" dannyben/completely preview

The difference between the 2 commands is that the first one writes the output into a file in the dir /app inside the docker container (which is mounted from $PWD) while the second command writes the output to stdout. It seems to me that there’s an permission issue when writing files inside a Docker file in a mounted directory.

I can redirect the output of the second command into a file which achieves the same as the first command and avoids “Error: EACCES”. However, the created file completely.bash uses CRLF instead of LF as line termination.

docker run --rm -it --user $(id -u):$(id -g) --volume "$PWD:/app" dannyben/completely preview > completely.bash