Problem description
In order to use VSCode to open the code in the container for easy debugging, install the Docker extension in VSCode. However, the error was found as follows:
ERROR: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/: Get http://%2Fvar%2Frun%/v1.24/info: dial unix /var/run/: connect: permission denied
Solution
1. Add the user to the Docker group
First, make sure that the current user has been added to the Docker group. Users can be added to the Docker group through the following command (assuming the user name isyour_username
):
sudo usermod -aG docker your_username
After adding, you need to log out and log in again for the changes to take effect.
2. Make sure the Docker service is running
Confirm that the Docker service has started. You can check the status of the Docker service using the following command:
sudo systemctl status docker
If the service is not running, you can start it with the following command:
sudo systemctl start docker
3. Check Docker socket permissions
Ensure Docker socket/var/run/
The permission settings of are correct. You can view permissions using the following command:
ls -l /var/run/
Normally, the output should be similar to the following:
srw-rw---- 1 root docker 0 date time /var/run/
If the permissions are incorrect, you can fix it with the following command (note: this is usually unnecessary, as it is automatically set when Docker is installed):
sudo chown root:docker /var/run/ sudo chmod 660 /var/run/
4. Use the newgrp command
In some cases, the terminal of VSCode may not load the new group permissions correctly. You can usenewgrp
Command activationdocker
Group:
newgrp docker
This will allow the current terminal session to gain Docker group permissions.
5. Restart VSCode
If the above steps do not resolve the issue, try quitting and restarting VSCode to make sure it loads user group changes at startup.
6. If you find that the docker extension still displays permissions after restarting VScode
Maybe it is because the ssh server of vscode has not been reset, or the old permissions are retained.
- Close code-server:
ps aux|grep bin/code-server # find out process id kill <process id>
- Then log in to vscode again.
At this time, you should be able to use the docker extension normally!
7. Plugins that allow Vscode to enter docker for debugging:
- docker
- Remote Development
8. If after vscode enters docker and starts python debug, it prompts that the python path is incorrect:
- Confirm python path: which python
- Press the shortcut key "Ctrl+Shift+P", enter "python: select interpreter", click "Select interpreter", and the Python environment found in the system will be listed, and click the required python interpreter.
Summarize
This is the article about the problem of enabling docker extension to display without permission in vscode. This is the end of this article. For more related content related to enabling docker extension to display without permission in vscode, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!