What are the dependencies and steps to connect to a remote docker container from VSCode? So I can properly compile and run the code with the tools in my container environment?
I have tried to follow the instructions here without much luck:
My setup involves:
Host
with VSCode, no docker installed, ssh client installed, ssh keys are in placeServer
with VSCode, docker installed, ssh client and server installedDocker container
already running on Server
Host
can connect to Server
, through VSCode using the Remote Development Version: 0.17.0
extension, through Remote - SSH Version: 0.47.2
extension
Version: 0.47.2
Server
can connect to Docker container
, through VSCode using the Remote Development Version: 0.17.0
extension, through Remote - Containers Version: 0.83.1
extension.
How do I connect Host
to a Running Docker container
?
UPDATE 1 Small advance
I have added this line to my ~/.config/Code/User/settings.json
file. The option gets highlighed with a message unknown configuration setting
{
...
"docker.host":"tcp://localhost:23750",
...
}
Run this command in another terminal:
ssh -N -L localhost:23750:/var/run/docker.sock <user>@<serveraddr>
And now I can see the running containers in Remote explorer
> Containers
> Other Containers
. However, when trying to connect to it, I get the following error message.
Setting up container with bc1700db049858ba20f1c830bbeff6d6a4e04de58a2b35a61df1016788bc07db
Docker returned an error code 127, signal null, message: Command failed: docker system info
/bin/sh: docker: command not found
So, it appears that docker must be installed on the host
machine to prevent the last mentioned error.
Note: docker service does not need to be running in the host
(systemctl disable docker
)
With this in mind, these are the steps.
Host
:
~/.config/Code/User/settings.json
with"docker.host":"tcp://localhost:23750",
Server
ssh -N -L localhost:23750:/var/run/docker.sock <user>@<serveraddr>
)Remote Development
extension. Restart VSCodeRemote explorer
> Containers
> Other ContainersServer
:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With