Docker WSL permission issues

Hello,

I am having issues with docker in terms of permissions. I am currently running Docker version 19.03.1, build 74b1e89.

Everything has been working fine for a couple of months, and then I restart my computer and then docker stops working("Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?") after some digging around I find out the user groups on WSL(Windows subsystem for linux). The solution I used to previously get it working again was to remove the group “docker” then add it again, and add my user to the group, worked fine for a couple of weeks.

I then have restarted my system since and it has caused the same issue with permissions however using the same solution has not worked and I have also tried multiple other solutions to no avail. I have already spent a good 4 hours trying to figure out what the issue is and a solution and this is getting ridiculous as I don’t want to spend a day every time I restart my system as this is just a waste of time…

Is anybody able to help me or guide me because I have searched everywhere for a solution.

On some system I have this line in ~/.bashrc:

export DOCKER_HOST=tcp://localhost:2375

This solution may be outdated with version 19 where we have docker context.

Thank you for your solution. However, the solution that seemed to work for me was to do with user groups in WSL and it was to use this command: sudo newgrp docker

Hope this will help someone!