When you install Docker for Visual Studio Code extension to your remote Linux server, it is probable that the extension fails to connect even if you have Docker containers running. To be precise, this is the exact error you are getting:

Both the the Docker documentation and VS Code documentations offer solutions. However, these are a bit long and cumbersome and there is a simple way to overcome this “Failed to connect. Is Docker installed and running?” error. What you need to check whether the user you’ve logged as is in the docker group.
First, check your user in the terminal:
whoami
#and we get:
ubuntu
Now that, we’ve learned that our username is ubuntu, let’s check if our user is in the group:
groups ubuntu
#and we get:
ubuntu : ubuntu adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd
As you see, there is no docker in the list. This means user ubuntu is not in the docker group and therefore getting the “Failed to connect. Is Docker installed and running?” error in the VS Code. Fortunately, the solution is simple. Just add the user to the group with a one line of code. I am a big fan on of one line codes:
sudo usermod -aG docker ${USER}
Let’s check again:
groups ubuntu
#and we get:
ubuntu : ubuntu adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd docker
Check the end of the output line. Ubuntu user is now in docker group.
The problem is solved. Don’t forget to reboot the server and the VS Code.
sudo reboot
After restarting the server, you are good to go:
