'Unable to mount /var/run/docker.sock from inside linux distribution (wsl 2)

I am unable to mount docker.sock when creating a container in WSL 2:

-v /var/run/docker.sock:/var/run/docker.sock

I get the following error:

docker: Error response from daemon: not a directory.

When navigating to /var/run, I can clearly see docker.sock being present, so I am unsure about why I am getting this error. docker ps correctly shows all the running containers.

Any help would be greatly appreciated!



Solution 1:[1]

Try to create a volume by passing this flag to the docker run command:

-v //var/run/docker.sock:/var/run/docker.sock

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex Mawashi