28

I get this error in Ubuntu in vscode and I can't see my images in vscode.

I run sudo docker ps -a and everything is OK on terminal!

What should I do to solve this problem?

enter image description here

enter image description here

2
  • 3
    Please if you solve it post an answer .... I have the same problem but in windows Commented Nov 13, 2021 at 15:23
  • @IbramReda Have you tried the following answer? Commented Nov 17, 2021 at 6:01

10 Answers 10

23

With the docker extension installed, workaround for me (on Mac) was:

  • (cmd-shift-p)
  • Go to "Preferences: Open Workspace Settings"
  • at the top of the settings, search for "docker path"
  • enter Absolute path to docker client executable (in my case "/usr/local/bin/docker")

setting for path to docker client executable

Hope this helps someone.

Sign up to request clarification or add additional context in comments.

4 Comments

For me it was a different path probably because I installed Docker desktop. I typed which docker, that gave me: /Applications/Docker.app/Contents/Resources/bin/docker
This worked for Windsurf as well. Thank you!
It doesn't work for me.
If you're on Unix (Mac/Linux) you can find the path by running which docker in the terminal. For Rancher Desktop macOS, the path is /Users/yourname/.rd/bin/docker
21

After an upgrade I got the permission denied. Doing the steps of 'mkb' post install steps don't have change anything because my user was already in the 'docker' group; I retry-it twice any way without success.

After an search hour this following solution finaly worked :

sudo chmod 666 /var/run/docker.sock

Solution came from Olshansk.

Look like the upgrade have recreate the socket without enough permission for the 'docker' group.

Problems

This hard chmod open security hole and after each reboot, this error start again and again and you have to re-execute the above command each time. I want a solution once and for all. For that you have two problems :

    1. Problem with SystemD : The socket will be create only with owner 'root' and group 'root'.

    You can check this first problem with this command :

      ls -l /lib/systemd/system/docker.socket
    

    If every this is good, you should see 'root/docker' not 'root/root'.

  • 2 ) Problem with graphical Login : https://superuser.com/questions/1348196/why-my-linux-account-only-belongs-to-one-group

    You can check this second problem with this command :

      groups
    

    If everything is correct you should see the docker group in the list. If not try the command

      sudo su $USER  -c groups
    

    if you see then the docker group it is because of the bug.

Solutions

If you manage to to get a workaround for the graphical login, this should do the job :

sudo chgrp docker /lib/systemd/system/docker.socket
sudo chmod g+w /lib/systemd/system/docker.socket

But If you can't manage this bug, a not so bad solution could be this :

sudo chgrp $USER /lib/systemd/system/docker.socket
sudo chmod g+w /lib/systemd/system/docker.socket

This work because you are in a graphical environnement and probably the only user on your computer. In both case you need a reboot (or an sudo chmod 666 /var/run/docker.sock)

Comments

13

I think it can be because your user is not in the docker group. Easily check the list of your user's groups using: groups <user>

And check in the output if you can see "docker".

If not, simply add the user to the docker group by typing:

sudo usermod -aG docker ${USER}

Don't forget to restart the VS Code and the system if necessary.

Comments

6

If you installed VS Code with the flatpak package manager (For example on PopOS) it will not detect docker. There is a Ubuntu deb VSCode package available

1 Comment

10x!! in all caps: FLATPAK is to blame!. it created so many problem with the paths. people need to know this.
3

I guess docker use unit socket communicate, which belongs to root user, and ordinary users need to use sudo to enable root permissions.

sudo groupadd docker          
sudo gpasswd -a $USER docker  
newgrp docker 

or

simply sudo chmod 777 /var/run/docker.sock

both do not forget reboot,

this methods work for me.

2 Comments

The part with using chmod 777 on the Docker socket, can pose security risks. Better use what is suggested in docker official documentation.
Part of the answer is not good practise.
2

I was able to fix this by restarting the remote machine. I also just installed Docker on an Azure instance and was starting development on a project. I added my user to the Docker group but they were somewhere/somehow logged in and I couldn't get Visual Studio code to understand the user was in the Docker group. I was doing the same, testing in the command line with another terminal session and the user was in the group, could call docker ps and so forth. Just not in Visual Studio code.

I restarted the remote machine, reconnected with VS Code and was able then to connect to Docker in VS Code which is going to make my life a lot easier.

(I can't post the screenshots because I lack the reputation)

Comments

1

I had to create docker group for themozel's solution to work.

Here is what worked for me:

Creates docker group

sudo groupadd docker

Add your user to the docker group

sudo usermod -aG docker $USER

1 Comment

Basically the docker group should be created automatically when you install docker. But if it is not there, then yes it should be done manually. Thanks for the tip.
1

The problem is docker is running as root but vs code trying to connect in user.

I am also having this problem. I solved this problem with install the Docker Engine

Delete the docker completely

sudo apt-get remove docker docker-engine docker.io containerd runc

Then install the Docker Engine https://docs.docker.com/engine/install/

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

If you installed VS Code from Flatpack (and probably from similar tools) it runs in its own isolated environment with its own shell and, in my case, my set of groups was different from normal - while in a normal shell I was a member of the "docker" group, in the VSC terminal I wasn't. There can be a number of issues related to this isolated installation. The solution is simple - uninstall your VSC and install it from a normal repository, just follow the instructions for your distribution.

Comments

0

I had the same problem in VS Code... I am using Ubuntu 20.04.6 LTS and this solution was good for me:

1 - Open the file /usr/lib/systemd/system/docker.service:

sudo nano /usr/lib/systemd/system/docker.service

2 - Append the following lines to the bottom of the Service section:

SupplementaryGroups=docker    
ExecStartPost=/bin/chmod 666 /var/run/docker.sock

3 - Restart the Docker daemon:

systemctl daemon-reload
systemctl restart docker.service

This article helped me with the resolution

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.