Vscode-docker: Unable to connect to Docker Machine

Created on 23 Oct 2018  路  16Comments  路  Source: microsoft/vscode-docker

Can't connect to docker even settings the DOCKER_HOST env var and on config file with DOCKER_HOST (tcp://192.168.99.100:2376)

Does that extension ever worked on macOS and Windows?

macOS: 10.14
VSCode: Version 1.28.2

P1

Most helpful comment

I found a fix. I've set docker.host like this, and it worked: "docker.host": "10.0.1.2:2376". Seems like the extension doesn't like the tcp:// prefix.

All 16 comments

@eduardonunesp Sorry you're having troubles. So you're trying to connect to Docker Machine? Have you followed the instructions at https://github.com/microsoft/vscode-docker#connecting-to-docker-machine?

@StephenWeatherford NP, sorry if I sounded rude, actually I have set the environment variable also the docker.host option on config file without success. I have tried also an year ago and it didn't work also

Same issue on MacOS 10.14 running VSCode 1.30.2 (1.30.2). Is there a ballpark timeframe for the PR on this one?

Same issue in Windows 10:

docker-machine start
& "C:\ProgramData\chocolatey\libdocker-machine\bindocker-machine.exe" env | Invoke-Expression
docker build --rm -f "Dockerfile" -t dr3x/dotnet-docker-vscode:latest .
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.39/build?
...
docker-vscode%3Alatest&target=&ulimits=null&version=1: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

Went through several iterations of setting the environment variables as per:
https://docs.docker.com/machine/reference/env/

I'm using docker-machine with a local VM provider (Virtualbox)

**Update - more info:
Works / connects if I put exactly the same command in the terminal; only get the error if I launch Docker:Build Image from the Command Palette. Maybe some issue with the way it is launched from VC?

I tried this setting:

"docker.host": "tcp://192.168.99.100:2376",
    "docker.importCertificates": {
        "useCertificateStore": true,
        "certificatePaths": [
            "/etc/ssl/certs/ca-certificates",
            "/etc/openssl/certs",
            "/etc/pki/tls/certs",
            "/usr/local/share/certs",
            "C:\\Users\\aksha\\.docker\\machine\\machines\\default"
        ]
    }

I get an error as (certificates are too big)

File size (4553637888) is greater than possible Buffer: 2147483647 bytes

and

Unable to connect to Docker. Please make sure you have installed Docker and that it is running. Details: connect ECONNREFUSED 127.0.0.1:80

Chiming in with the same issues as above. I've run eval $(docker-machine env vm) and the output of env | grep DOCKER is:

DOCKER_TLS_VERIFY=1
DOCKER_HOST=tcp://192.168.64.100:2376
DOCKER_CERT_PATH=.../.docker/machine/machines/vm
DOCKER_MACHINE_NAME=vm

However, I'm unable to view my containers in my Docker Machine VM on the explorer. Is there a step that I'm missing in the settings?

Actually, I just happened across this issue https://github.com/Microsoft/vscode/issues/69728 and out of curiosity tried launching code from the command line. Looks like this solved the issue, but it's unintuitive. I can see all of my Docker Machine containers and attach VSCode (using Remote Containers and Insiders)

  • Tried https://github.com/microsoft/vscode-docker/issues/914 and could not reproduce the same error, but I did not get any further either.
  • @JDDoesDev I tried your solution and unfortunately it did not work for me, could you provide more information? Maybe I'm missing an important detail. I still see Unable to connect to Docker. Please make sure you have installed Docker and that it is running. Details: connect ECONNREFUSED 127.0.0.1:80, even though I've set a the configs in settings.json, set the environment variables and started vscode using code from the terminal in which the env variables are set.
  • I've tried what @akshaybabloo said and got the same error File size (11848777728) is greater than possible Buffer: 2147483647 bytes on a mac. I do not believe it is correctly pointing to certificates because 11GB is huge for a certificate isn't it? It's actually pointing to a virtualbox disk file .vmdk for me, not the pem's or pub keys. Changing the path to point directly to the key file does remove this error, but I am still stuck with this error afterwards: Unable to connect to Docker. Please make sure you have installed Docker and that it is running. Details: connect ECONNREFUSED 127.0.0.1:80 again, regardless of the suggestions above.

I would appreciate a fix for this soon, the extension works when i'm not using docker-toolbox but I need to run both docker and docker-toolbox on different machines at the same time.

@deepio Did you use code or code-insiders? Also, after you run env | grep DOCKER what is the output?

Another question: are you changing out the vm in my command for the name of your docker machine?

EDIT: eval $(docker-machine env <YOUR MACHINE NAME HERE>) is what the command should look like

Reading back, I don't know whether or not docker toolbox is supported. is it possible for you to migrate from toolbox to docker machine instead or is that a non-starter?

@JDDoesDev I really appreciate your speedy reply. I'm using code not code-insiders, I will try the latter. Yes, my vm is called default and i'm using default.

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.101:2376"
export DOCKER_CERT_PATH=".../.docker/machine/machines/default" # On my machine this is actually a symbolic link to another drive, but I don't think that should be an issue because docker runs just fine outside of vscode
export DOCKER_MACHINE_NAME="default"
# Run this command to configure your shell: 
# eval $(docker-machine env)

Unfortunately I need to run both docker and docker-toolbox, it's not just one or the other. It would have been nice to have vscode integration for all the machines but I believe it might not be possible at this time.

Edit: I've also tried with the --no-proxy flag docker-machine env --no-proxy default

@deepio I'm sorry, code-insiders was for a different issue. Sometimes I git confused... yeah, I went there.

The output up there looks like something from a .*rc file or similar. What happens when you actually run eval $(docker-machine env) and then run env | grep DOCKER? I mean the actual output. Can you paste that?

@JDDoesDev what I posted was just the output of docker-machine env, which gets executed by eval. env | grep DOCKER would just check to make sure those environment variables have been set in the shell and I can confirm that they are present and it still did not work. So sadly it would appear that this extension does not work with docker-toolbox at all.

I found a fix. I've set docker.host like this, and it worked: "docker.host": "10.0.1.2:2376". Seems like the extension doesn't like the tcp:// prefix.

I found a fix. I've set docker.host like this, and it worked: "docker.host": "10.0.1.2:2376". Seems like the extension doesn't like the tcp:// prefix.

Save my day! Thank you very much!

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

Was this page helpful?
0 / 5 - 0 ratings