Remote Docker Visual Studio Code - No running containers - Mac OS - docker

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"

Related

Visual Studio w/Docker has exited with code 4294967295 (0xffffffff)

On our new company laptops we are running into issues running containers in docker desktop from visual studio. We tried a bunch of things which were unsuccessful. Any help / thoughts would be great as we are running out of ideas.
.Net Core Version 6 / Asp.net Core (web api)
Running docker compose manually in cmd works and I'm able to hit the site.
Running docker compose debug profile from visual studio results in:
The output window shows "The program '' has exited with code 4294967295 (0xffffffff)."
Docker desktop shows the container running but I can't grab logs from it or hit it in the url.
WSL is fine and everything is working there.
My home machine works great and i'm able to launch and debug containers.
Faced with identical error, I was able to resolve by deleting VSDBG debugger folder:
%USERPROFILE%\vsdbg\vs2017u5
After deleting the folder start Visual Studio debugger (F5) and as a result VSDBG debugger will be recreated
Container Tools build properties https://learn.microsoft.com/en-us/visualstudio/containers/container-msbuild-properties?view=vs-2022
I have the same error when I'm trying to start 2 project simultaneously. And one project was cloned from another. So, they have the same GUIDs of projects in .sln files. After changing GUIDs all works ok.
Most of the time this error code does not provide any concrete information. In my case I had to go and find error details in logs folder. Log file is generally located at 'YourProject\bin\Debug\App_Data\Logs' location.
There was an issue with 3rd party service and it worked after fixing the service issue.

How to import a project from Docker into Android Studio

I am using this repo github.com/opengisch/QField to create a Docker image. It all went ok and I can see the Docker container is running. This runs a local machine and I am not able to see where the files downloaded by Docker are saved on Widows 10. I have not used Docker before.
I need to open this project in Android Studio but I cannot find any guide how to do this. I have tried to locate files and directly download to Windows but dont seem to have any luck.

Docker - Was trying to move Docker off my C: drive, messed something up now I can't reinstall it (Windows 10)

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

VS Code "Attach Visual Studio Code" to remote container error

I am trying to develop in a remote container.
I run VS Code on my local windows machine.
I have a linux machine which runs docker and a bunch of containers.
I have the "Remote - Containers" and "Remote - SSH" extensions installed in VS Code.
I can connect to my linux machine in VS Code and I can see the running containers.
I can right click on a container and choose "Attach Shell". This works fine:
When I right click on a container and choose "Attach Visual Studio Code" I get an error:
UPDATE
The above error was raised because (for some reason?) docker must be running locally on windows also even though we are fully on a remote machine. I've installed and run docker locally.
Now when I right click on a running container, I get a different error:
Of course the containers are running -- I see them.
How can I Attach Visual Studio Code to a running remote container successfully?
This may not be a real answer but it's too much for a comment.
I believe you have a local machine and docker on a remote server.
The first thing you have to do is to install docker on your local machine and configure it so that's its looking for the docker host on your remote server.
Then you can create a .devcontainer.json on your machine. If you have the extension installed, VSCode will offer you do open this as container environment. Since your docker host sits on remote, this will now happen on your server instead of your local machine.
When I did the setup, I followed amongst other things this guide. Especially the SSH-Agent was required to get a remote docker host working. https://code.visualstudio.com/docs/remote/containers-advanced#_a-basic-remote-example
Here is a example .devcontainer file of mine.
Now back to your initial question, I don't think you will be able to use the remote container extension on a container that wasn't started as dev container. This is because vscode will install a bunch of stuff in there when its first set up. Similar to the SSH Extension. I may be wrong on this so take it with a grain of salt.
It may also be worth noting that once you connect to your server via SSH and have then the regular docker extension (which is not the remote container extension) installed, on remote, you will see your docker images listed there. But that does not mean you will be able to connect like that from local to remote container. For that you need to configure a docker remote host.
I have also faced similar issue after doing some research I found the issue was with my installation.
But I faced this issue when I installed vs-code through snap in Ubuntu.
May be try uninstalling VS Code and reinstalling it.
It should work if Docker is installed properly.

Open Containers in Remote SSH Hosts using VSCode

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.

Resources