/home/ranger/.m2 is mounted as volume to you local home user directory ~/.m2
volumes:
- ${HOME:-~}/.m2:/home/ranger/.m2:
So you should be confident that that directory ( ~/.m2 ) have owner (your local user) or have write access to your local user