Permission denied error when building a docker image in MAC

Here is the command, which i am using to build a docker image in MAC with docker desktop installed

docker build -t my_first_image .

I get the following error message

ERROR: open /Users/rajesh/.docker/buildx/activity/desktop-linux: permission denied

I also tried to build the docker image using sudo command

sudo docker build -t my_first_image .

Error message

+] Building 1.1s (2/3)                                    docker:desktop-linux
[+] Building 1.1s (3/3) FINISHED                           docker:desktop-linux
=> [internal] load .dockerignore                                          0.0s
=> => transferring context: 2B                                            0.0s
=> [internal] load build definition from Dockerfile                       0.0s
=> => transferring dockerfile: 1.66kB                                     0.0s
=> ERROR [internal] load metadata for     1.6st
> [internal] load metadata for
   1 | >>> FROM alpine:latest
   2 |     CMD ["echo", "Hello StackOverflow!"]
ERROR: failed to solve: alpine:latest: error getting credentials - err: exit status 1, out: ``