I would like to open VSCode from the terminal, but instead of opening a directory or file, I would like to attach the VSCode session to a running container using the Dev Containers extension.
I have tried using the --folder-uri flag with the vscode-remote option as suggested here (i.e., code --folder-uri=vscode-remote://<container name> --verbose) which does not seem to open anything.
Related
I was trying to move Docker off my C: drive using the guidance below:
https://forums.docker.com/t/how-could-i-install-docker-for-windows-on-drive-e-my-ssd-c-is-full/52347/12
I completed the final step: sc.exe config com.docker.service binPath=“D:\Program Files\Docker\com.docker.service” and it seemed to work. But when I went to run Docker, it wouldn't run, so I deleted it off my E: drive.
But now, when I try to reinstall it, it says Docker is already installed. I go to Apps & Features to uninstall it, but it gives me:
Windows cannot find 'C:\Program Files\Docker\Docker Desktop Installer.exe'. Make sure you typed the name correctly, and then try again.
Having had Docker removed from my PC and running into the same issue while reinstalling, the only way that worked for me was looking up the Docker application within the Windows Registry Editor and deleting it from there.
You would need to open up Registry Editor or use Run and type in regedit, and within this path look for anything mentioning "Docker", "Docker Desktop" or the path that windows "cannot find":
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
source from when I had issues: https://github.com/docker/for-win/issues/1371#issuecomment-347926743
I have a docker image with a medical data analysis app installed in it. The app works from both gui and console. Normally, in my linux, I run the app from the terminal as
./dsi_studio --action=trk ...
and it works quite smoothly. If you click on this app, it'll try to open a GUI. While I'm trying to use this inside the docker image, it tries to connect to the display in any case (even if I run as shown in the terminal). And, of course, since I didn't do any setup for showing GUI from docker, I get the following error, stating that it couldn't find a display to connect.
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
I don't know why the app is trying to open a display while running in terminal, because it doesn't open a GUI in my linux. I just want to suppress this warning somehow, as if there is a fake display. I don't want to connect my display to docker image, because this image is going to run in batch in an HPC.
So, How can I do this?
You should probably export the DISPLAY environment variable to point to your linux terminal.
Just to test, run
xhost +
in your linux terminal and add
-e DISPLAY=:0.0
to your docker command line
Setup:
Ubuntu 20.04 distro running inside WSL2 (5.4.72-microsoft-standard-WSL2)
VS Code version 1.55.2 installed in Windows
Docker version 19.03.8, build afacb8b7f0 installed in WSL2
docker-compose version 1.29.0, build 07737305 installed in WSL2
Remote-Containers Extension for VS Code v0.166.1 installed locally (I could not find an option to explicitly install this inside WSL2, but I am not sure if this even matters, see below)
Original error:
When I open the command palette and enter Remote-Containers: Rebuild and Reopen in Container, I get the error `The 'docker' command was not found. Make sure Docker is installed' in a pop up window.
What I tried:
Attempt 1
First, I thought that the Remote-Containers extension wants to execute the docker commands inside windows and not WSL2. Since I don't have Docker Desktop installed on Windows, it is impossible to execute docker commands in Windows. So I tried downloading a specific version of the the Remote-Containers extension file from the marketplace v0.165.0 I believe, copying it into the VS extension folder inside WSL2 /home/kevinsuedmersen/.vscode-server/extensions and installing it manually from the VS Code Extension panel. However, this also installed the Remote-Containers extension locally, so probably on Windows. I am not sure if locally means that this extension is available globally, but nevertheless, I am still getting the error that the docker command is not found as explained above.
Attempt 2
I notice that when I open a PowerShell on Windows, I can use the docker daemon inside WSL2 by prepending wsl to all docker commands, e.g. wsl docker run hello-world. So, I went to the VS Code and in settings (Settings > Remote > Containers > Docker Path), I changed the docker path from docker to wsl docker, but then, I got this error Docker Desktop WSL 2 backend required. This is even the case on another laptop, where I actually have Docker Desktop installed and the WSL2 backend enabled.
Attempt 3
I tried changing the docker path in VS code to the full path of the docker socket in WSL2 /var/run/docker.sock, but then I got the error Current user does not have permission to run 'docker'. Try adding the user to the 'docker' group. My current user kevinsuedmersen is already member of the docker group.
Any advice or directions are greatly appreciated.
Answer was given on the GitHub Repo of the VS-Remote-Container Extension here: https://github.com/microsoft/vscode-remote-release/issues/4914
I am trying to Attach VS Code Window into a Docker container inside my remote machine on Azure.
It has stopped working at some point, the message is "There are no running container to attach to", but clearly there is one because it finds it in the Docker extensions.
These are my steps.
Open VS Code
SSH-Remote Development to open VS Code on the Remote machine and install Docker extension there
I find the docker container in the remote machine, but it fails opening it.
I attach here a screenshot.
I have tried this issue of possibly being because of opening VS Code from Spotlight instead of the Terminal, but is not the case.
Thanks !
I had the same issue, but opening a folder first, on the VSCode instance on the remote machine, seems to solve the problem for me.
File > Open Folder > "chose a folder"
Using the Remote Development extension pack, Visual Studio Code is able to open a Docker container running on the current system, and to open a folder on a remote host connected using SSH.
If there is a Docker container running on a remote SSH host, how can VSCode open a file/folder in this container?
So you want to open a folder inside a container in a remote SSH server. Following are the steps through which I achieved it.
Step 1
install Remote Development extension in VSCode and open its control panel
Step 2
Connect VSCode to remote SSH server
Step 3
Upon connecting you'll notice a green tick sign, means you are connected to remote server, now select Containers from Remote Explorer dropdown. You'll see a list of containers. If you don't see the list of container or if you see list of local containers then follow along, otherwise move to Step 4.
Step 3.1
Add new context to your docker by executing following commands in terminal.
$ docker context create my-remote-docker-machine --docker "host=ssh://username#host:port"
$ docker context ls
$ docker context use my-remote-docker-machine
Step 3.2
$ docker ps -a
You'll notice that above command lists all the containers from remote server now (its because of the context which you just added)
Lets come back to VScode now, click on Docker from side bar menu, You'll notice a warning Failed to connect. Is Docker Running? know more about this bug
Troubleshooting
Verify that Docker extension is installed on the remote machine. As of
February 2020 there is a bug in VS Code that prevents the Docker
extension to be installed remotely if it is already installed locally.
This bug is scheduled to be fixed in VS Code 1.43 release. A
workaround to get the extension installed remotely is described here.
Uninstall Docker extension from VS Code. Close all VS Code windows.
Start VS Code again. Use `Remote-SSH: Connect to Host..' to connect to remote machine.
Open extension marketplace and install Docker extension on the remote machine (see screenshot below)
Once the Docker extension is installed remotely, it can also be installed locally.
Step 4
From the containers list select the target container which you want your VSCode to connect to.
Step 5
Vala! VSCode is connected to the container inside remote server, you can click on Explorer and select any folder/directory inside container and start working in that directory.