Docker login into kube cluster

I’ve create a private repo on docker hub and trying to pull that image into my kubernetes cluster. I can see the documentations suggest to do this


kubectl create secret generic regcred
--from-file=.dockerconfigjson=<path/to/.docker/config.json>
--type=kubernetes.io/dockerconfigjson

I am already logged in, and i change path to ~/.docker/config.json but it keeps giving me

error: error reading ~./docker/config.json: no such file or directory

despite the fact if i type cat ~/.docker/config.json it displays the content, meaning there is a file.

So in other words how to properly authenticate and be able to push private images into kube cluster?

Source: StackOverflow