Search code examples
macosdockervisual-studio-codesshcontainers

VSCode remote explorer not showing remote containers


I followed the instructions here,

https://code.visualstudio.com/docs/remote/containers-advanced#_developing-inside-a-container-on-a-remote-docker-host

I added

"docker.host":"ssh://your-remote-user@your-remote-machine-fqdn-or-ip-here"

to my settings, but the container is not showing up in my remote explorer's containers section. I figure that I should use remote-ssh in vscode to log into the server which contains the remote server, since vscode can't read stuff on the server until I logged on. But after I connect, the container is still not showing up in my remote explorer's containers section.

I then tried to connect using the remote-containers: attach to running container command, but the command is not available after I connect to the server. What is also notable is that

"docker.host":"ssh://your-remote-user@your-remote-machine-fqdn-or-ip-here"

in my settings has been darkened. When I hover my mouse over it, it says

This setting cannot be applied in this window. It will be applied when you open local window.

I wonder if this means that after I connect to the server, I shouldn't use remote-containers because the remote-server is basically treated as my local server after I log in.

In my connected VSCode window, if I go to the docker extension tab, all the remote containers are there.

So now I'm trying to figure out how do attach to my remote container from the unconnected vsscode. I suspect that I need to use my private key somewhere like how remote-ssh has a config file for the key, but I don't see that in the instructions.

If it makes a different, I am using MacOS


Solution

  • I can attach to remote runinng containers. But I could reproduce your problem by replacing the section in settings JSON about docker.host to something that clearly should not work: for instance literally typing in "docker.host":"ssh://your-remote-user@your-remote-machine-fqdn-or-ip-here" or using an incorrect login etc.

    Now I cannot attach to the running containers anymore and the remote explorer does not show them. This matches your observation.

    After connecting to the remote host by clicking on the status bar in the bottom-left corner, I tried to edit the settings JSON. Here, the field for docker.host is also greyed out.

    This suggests that one possible explanation for your problem is that you put down an incorrect value for the docker.host field. To check that it is indeed incorrect, try to ssh to the host machine from the terminal using that exact login, which you used as a value here. If you get that to work, I would expect your problem to be solved. (In this context you may find it helpful to look up password-less SSH connections somewhere.) Good luck!