I resolved this problem by switching to the remote server's Docker context on my local machine:

docker context create some-context-label --docker "host=ssh://user@remote_server_ip"

docker context use some-context-label

docker ps
# A list of remote containers on my local machine! It works!

After that:

  1. Connect via Remote-SSH to the container server
  2. Right click relevant container -> the "Attach Visual Studio Code"

That works for me.

(Note: One would think that I should be able to just use my local VSCode (skip step 1) to connect to said remote container after switching my local context, but VSCode complains Failed to connect. Is docker running? in the Docker control pane.)

Answer from Daniel on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › remote › advancedcontainers › develop-remote-host
Develop on a remote Docker host
November 3, 2021 - Sync files from the remote host to your local machine using rsync. Use the mount command if you are using Docker Machine. Using SSHFS or Docker Machine's mount command are the more convenient options and do not require any file sync'ing. However, performance will be significantly slower than working through VS Code, so they are best used for single file edits and uploading/downloading ...
Top answer
1 of 11
28

I resolved this problem by switching to the remote server's Docker context on my local machine:

docker context create some-context-label --docker "host=ssh://user@remote_server_ip"

docker context use some-context-label

docker ps
# A list of remote containers on my local machine! It works!

After that:

  1. Connect via Remote-SSH to the container server
  2. Right click relevant container -> the "Attach Visual Studio Code"

That works for me.

(Note: One would think that I should be able to just use my local VSCode (skip step 1) to connect to said remote container after switching my local context, but VSCode complains Failed to connect. Is docker running? in the Docker control pane.)

2 of 11
8

This might sound very strange, but for me, I had to open a folder on the remote SSH server prior to using the Remote Containers extension in VS Code. If I didn't do that, then it would constantly try to find the docker service running locally, even though the terminal tab was connected to the remote SSH server.

This seems very weird, because if you're conncted via SSH in VS Code, then the extension should assume you're trying to attach to the container on the remote server. Shouldn't have to open a remote folder first.

By "opening a folder" on the remote server, the Remote Containers extension was then able to attach VS code to the container running on the remote SSH server. I didn't have to do any of the steps in any of those articles. Just simply use Remote SSH to connect VS Code remotely via SSH, open a folder, and then use Remote Containers.

Discussions

VSCode remote Docker
I’d like to use this droplet as remote Docker server for VSCode development, I have Windows 11 with WSL2. If it is easy, I’d like next level - set up Windows… More on digitalocean.com
🌐 digitalocean.com
3
October 24, 2024
How to use VScode in a container in a remote machine?

Likely you are after https://GitHub.com/coder/coder or https://GitHub.com/coder/code-server

More on reddit.com
🌐 r/docker
16
0
December 16, 2022
How to set up development in remote Docker container?
https://code.visualstudio.com/docs/remote/containers-advanced#_developing-inside-a-container-on-a-remote-docker-host More on reddit.com
🌐 r/vscode
6
13
July 30, 2019
Connecting to a remote container on a remote host?
Probably you could workaround this by running an ssh server in the container, port forwarding and connecting directly via the Remote SSH extension? More on reddit.com
🌐 r/vscode
9
10
September 14, 2022
🌐
Visual Studio Code
code.visualstudio.com › remote › advancedcontainers › overview
Advanced container configuration
November 3, 2021 - Installation - How to install Docker, VS Code, and the Remote Development Extension Pack.
🌐
Microsoft Community Hub
techcommunity.microsoft.com › microsoft community hub › communities › topics › education sector › educator developer blog
Using Visual Studio Code from a docker image locally or remotely via VS Online | Microsoft Community Hub
June 17, 2020 - You can run this container from VSCode locally see https://code.visualstudio.com/docs/remote/containers. ... Install and configure Docker for your operating system.
🌐
Visual Studio Code
code.visualstudio.com › docs › containers › ssh
Connect to remote Docker over SSH
November 3, 2021 - We recommend using the Visual Studio Code Remote - SSH extension to connect to a remote machine running Docker engine. You can use the Remote - SSH and Dev Containers extensions together.
🌐
Rancher Desktop
docs.rancherdesktop.io › vs code remote containers
VS Code Remote Containers | Rancher Desktop Docs
Install and launch Rancher Desktop. Select dockerd (moby) as the Container Runtime from the Kubernetes Settings menu. Install and launch Visual Studio Code or Visual Studio Code Insiders. This tutorial uses Visual Studio Code. Install the Remote Development extension pack.
Find elsewhere
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › containers
Developing inside a Container
November 3, 2021 - Add your user to the docker group by using a terminal to run: sudo usermod -aG docker $USER · Sign out and back in again so your changes take effect. Install Visual Studio Code or Visual Studio Code Insiders. Install the Dev Containers extension.
🌐
DigitalOcean
digitalocean.com › community › questions › vscode-remote-docker
VSCode remote Docker | DigitalOcean
October 24, 2024 - Then, in VSCode or Docker Desktop, point to tcp://localhost:2375. ... Yep, that is doable. You would need to first set up remote access for Docker daemon on your Droplet as described here:
🌐
Dlford
dlford.io › home › blog › setting up a remote docker vscode development server
Setting up a Remote Docker VSCode Development Server | dlford.io
September 2, 2025 - Since I plan to re-create the code_server container every now and then with the latest image, I’ll create an install script in the project folder to configure anything that won’t be stored in the vscode directory (home folder). ... Install NodeJS, the FiraCode font, and docker-compose via Python (I know you can just download the executable, but I want Python installed anyway)
🌐
GitHub
github.com › microsoft › vscode-remote-release
GitHub - microsoft/vscode-remote-release: Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set. · GitHub
Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set. - microsoft/vscode-r...
Starred by 4.1K users
Forked by 438 users
Languages   Dockerfile
🌐
Reddit
reddit.com › r/docker › how to use vscode in a container in a remote machine?
r/docker on Reddit: How to use VScode in a container in a remote machine?
December 16, 2022 - Log into the remote machine with SSH from VScode and once done install docker remote extension on that remote box.
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › tutorial
Dev Containers tutorial
November 3, 2021 - Download and install Docker Desktop, or an alternative Docker option, like Docker on a remote host or Docker compliant CLI.
🌐
Opengeosys
opengeosys.org › stable › docs › devguide › advanced › vscode-devcontainer
Develop with VS Code Remote – Containers
September 23, 2025 - Install VS Code. Inside VS Code install the Remote Development extension pack (includes Remote – Containers and Remote – SSH extensions). Open VS Code. Open the OGS source code folder. Press F1 and type reopen in [container], press ENTER. This takes now some time as the container is downloaded ...
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
Dev Containers - Visual Studio Marketplace
Extension for Visual Studio Code - Open any folder or repository inside a Docker container and take advantage of Visual Studio Code's full feature set.
🌐
ASP.NET Hacker
asp.net-hacker.rocks › 2021 › 02 › 04 › remote-docker.html
Working inside a Docker container using Visual Studio Code
February 4, 2021 - The local VSCode will connect to the remote VSCode server and mirrors it in the user interface of your locally installed VSCode. It is like a remote session to the other machine but feels local. ... FROM mcr.microsoft.com/dotnet/sdk:5.0 COPY . /app WORKDIR /app EXPOSE 5000 5001 # ENTRYPOINT ["dotnet", "run"] not needed to just work in the container · If you don't have the docker tool installed, VSCode will ask you to install it as soon you have the dockerfile open.
🌐
GitHub
gist.github.com › tdamsma › 06cafea175d6784aea7b3634bb9495c8
Running VSCode remote containers on windows without docker desktop · GitHub
>> sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 2db29710123e: Pull complete Digest: sha256:975f4b14f326b05db86e16de00144f9c12257553bba9484fed41f9b6f2257800 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. ... To enable docker buildkit you need to set DOCKER_BUILDKIT=1. However if you set that in ~/.zshrc this doesn't get loaded when VSCode calls docker.
🌐
Lei Mao's Log Book
leimao.github.io › blog › VS-Code-Development-Remote-Host-Docker
VS Code Development Using Docker Containers on Remote Host - Lei Mao's Log Book
June 6, 2020 - Setting up a containerized development ... to the remote containerized development environment via local IDEs are necessary. It turns out that VS Code could do this with its extensions. In this blog post, I would like to talk about how to set up the VS Code Docker development ...
🌐
DEV Community
dev.to › graezykev › dev-containers-part-4-remote-dev-develop-on-a-remote-docker-host-440l
Dev Containers - Part 4: Remote Dev - Develop on a Remote Docker Host - DEV Community
June 21, 2024 - Use a spare laptop (with Windows, Mac, or Linux OS) to install VS Code, login with the GitHub/Microsoft account, and connect to the remote machine via "Remote Explorer" (Don't forget to install the Remote Development extension pack). If you don’t want to install anything, use a tablet device like an iPad to visit the vscode.dev URL and start developing.