Vscode-docker: Connect to remote docker host

Created on 19 Feb 2018  路  16Comments  路  Source: microsoft/vscode-docker

Currently it's possible to override the default behavior of this extension by following the steps here: https://www.axians-infoma.de/navblog/use-vs-code-docker-extension-remote-docker-host/

Which end up setting the DOCKER_HOST environment variable.

Instead can we have a setting that does the same? Allowing different docker hosts to be used depending on the workspace?

P2 help wanted

Most helpful comment

Please implement this! I need to switch between local and remote Docker environment without restarting VSCode.

Note that it's not just DOCKER_HOST, but also DOCKER_MACHINE_NAME, DOCKER_TLS_VERIFY and DOCKER_CERT_PATH that need to be configurable.

All 16 comments

There are two challenges here.

First, the extension uses a mix of dockerode and the docker CLI. For example, it uses dockerode to enumerate images, containers, etc. for the Explorer. It also uses dockerode for commands like system prune and starting/stopping containers. The docker CLI is used whenever a terminal is spun up, for example when running a build. These APIs/CLIs look for the environment variable DOCKER_HOST, they do not have APIs for setting value directly. So, I would need to use something like dotenv for the dockerode APIs and then pass the DOCKER_HOST environment variable when creating new terminal instances. Do-able, but kind of messy.

The second problem is when you have multiple root workspaces open. Which .env file do I use and how does the user know? I would have to have a setting that would point to the appropriate .env file to use when the workspace is opened and if none exists then what is the behavior?

actually, I can't seem to get dotenv to load before dockerode...

I'm sharing the same problem but the first challenge seems solvable for me: The dockerode API provides an overloaded constructor for such cases, and the docker CLI can be covered by injecting the environment variable with TerminalOptions when creating a new integrated terminal instance. Thus, each CLI/API call can address an individual docker host. Or have I missed some limitations?

Please implement this! I need to switch between local and remote Docker environment without restarting VSCode.

Note that it's not just DOCKER_HOST, but also DOCKER_MACHINE_NAME, DOCKER_TLS_VERIFY and DOCKER_CERT_PATH that need to be configurable.

+1, I would love to be able to use different docker environments per workspace, change servers without reloading VSCode, and not have to run commands before starting VSCode to connect to a remote SSL machine.

You can set this with the setting docker.host. Am I misunderstanding something?

Lets say i want to connect to docker engine on remote linux server (with TLS=1) from my local mac via vscode, how do we do that today ? Just changing docker.host doesn't solve it. We need DOCKER_TLS, DOCKER_TLS_VERIFY support as well.

It would be way easier if we could install the extension on the remote host via vscode remote preview.

Hi all - just merged #998 to support the following VS Code settings:

docker.host - equivalent to DOCKER_HOST
docker.certPath - equivalent to DOCKER_CERT_PATH
docker.tlsVerify - equivalent to DOCKER_TLS_VERIFY
docker.machineName - equivalent to DOCKER_MACHINE_NAME

Feel free to try the latest build from master and let us know if it works for ya! See these instructions: https://aka.ms/azCodeInsiders

Hi there, I'm trying to enable the tlsVerify setting and have set the value to '0' and still not able to connect to registries using self signed certificates.

I'm running VSS: 1.36.1 and ms-azuretools.vscode-docker: 0.7.0 of this extension. Any idea when this will become generally available?

@moortimis moved your comment to a new issue. https://github.com/microsoft/vscode-docker/issues/1137

@EricJizbaMSFT In my production scenario, we are using these env variables
DOCKER_HOST
DOCKER_CERT_PATH
DOCKER_TLS and
DOCKER_API_VERSION

Could you please add these two new env variable support as well ?

Between i tried this alpha preview of docker extension. Looks like if we just set DOCKER_HOST, DOCKER_CERT_PATH (Not settting any value for "DOCKER_TLS_VERIFY" ), TLS_VERIFY automatically kicks in.

Ideally it will be great if the extension can support all the client modes mentioned in
https://docs.docker.com/engine/security/https/

Screen Shot 2019-07-26 at 8 25 18 PM

One more issue i observed that with docker extension explorer refresh, i see docker engine is leaking fd in every polling. With the default refresh interval of 1sec, i see docker engine pretty quickly hitting the soft limit of max open files and breaks down the engine. Before reporting to docker project, i would like to understand how this extension is querying the docker engine. Pls investigate. I am using docker engine version 18.03 and latest alpha version of this docker extension

@sureshsankaran you can change the default refresh interval with the VS Code setting docker.explorerRefreshInterval

Otherwise, please create a new issue for your other comments so that we can track it separately from this already closed bug

thanks opened below issues
1168
1169

Was this page helpful?
0 / 5 - 0 ratings