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.
Related
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 learn Docker and have installed it on my laptop. I have tried to uninstall it and delete the Docker directory as Administrator, but keep getting the error message "The action cannot be completed because the file is open in Docker Desktop service". But Docker Desktop Service is not open, and does not appear whenever I open Task Manager. When I try to reinstall Docker, it says it it up to date, when clearly it is not. I would appreciate any help getting a fresh installation of Docker.
Here is the Docker directory C:\Program Files\Docker\Docker.
Here is the error message.
If you have access to the windows machine, through UI, you can:
Go to Start -> Services, and search for the Docker (probably is called Docker Desktop or something similar) service and
Manually Stop. You can also set the service to start Manually, not Automatically, give a restart and
Now Docker is completely stopped and
You can uninstall safely.
User azbarcea answered the question.
I want to do demonstrate to the IT area at my work how one might use a container for isolated development. I have installed WSL2, then I have a development container running with some basic developer tools--OpenJDK, etc. I can SSH into the container from a WSL2 terminal simply by running ssh user#172.17.0.2, for example, but I cannot figure out how to SSH into this from Windows. More importantly, I want to be able to SSH into the running container from Visual Studio Code via Windows, but things just seem to time out. Does anybody know how to get this going? I have a very locked-down IT environment and I want to do this without having to install Docker for Windows (which I doubt my IT department will ever approve).
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.