getting Invalid Reference Format while executing docker run

While executing below script,

sudo docker run -volume "$PWD:/build" -volume "~/.m2:/root/.m2" -volume "~/.build:/root/.build"`

i am getting below error:

docker: invalid reference format.
See 'docker run --help'.

OS using is ubuntu-18. Followed some stackoverflow threads, but missing something.

Source: StackOverflow