When I tried to run a Docker command in Visual Studio Code’s terminal, I encountered the “Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get “http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json”: dial unix /var/run/docker.sock: connect: permission denied” error.
I can’t also use the command “docker-compose up” to start and run an entire app on a standalone host that contains multiple services like DB.
Therefore, this is a fix for the issue. All you need to do is type the codes below into your VS Code prompt.
sudo chmod 666 /var/run/docker.sock
sudo setfacl --modify user::rw /var/run/docker.sock
After that, you can verify whether Docker commands now function.
I hope this was helpful. Thank you very much!