Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Docker provider fails to connect via SSH or non-TLS TCP on WSL (Windows) #210

Closed
badgerwithagun opened this issue Oct 14, 2019 · 2 comments

Comments

@badgerwithagun
Copy link

badgerwithagun commented Oct 14, 2019

Terraform Version

Terraform v0.12.10

  • provider.docker v2.4.0

Affected Resource(s)

Provider

Terraform Configuration Files

provider "docker" {
  host = "ssh://root@myhost.example.com:1234"
}

(note that the address and port are faked in this example).

Steps to Reproduce

  1. terraform init
  2. terraform apply

Expected Behavior

The following works:

docker -H ssh://root@myhost.example.com:1234 run -ti alpine echo "Hello"

So Docker is connecting just fine via SSH (no public key issues or anything). Therefore I'd expect the above configuration to work.

Actual Behavior

Error: Error pinging Docker server: error during connect: Get https://root%40myhost.example.com:1234/_ping: dial tcp: lookup root@myhost.example.com: no such host

It's picking up the host name correctly, but the https is suspicious.

Debug Output

https://gist.github.com/badgerwithagun/5020bdf6daab139716b2125f927413c1
(Note - search & replaced real hostname, paths etc to match the example - please just take it as assumed that I've checked that stuff!)

Panic Output

None

Important Factoids

  • Client is Ubuntu 18.04.3 LTS on Windows Subsystem for Linux
  • This also occurs if I remove the host in the provider definition and instead set DOCKER_HOST before calling terraform apply. Terraform picks up the host name correctly from DOCKER_HOST, but still produces the same error message implying it's not using SSH.

References

None

@badgerwithagun badgerwithagun changed the title Docker provider 2.4.0 not working with ssh:// protocol Docker provider fails to connect via SSH or non-TLS TCP on WSL (Windows) Oct 14, 2019
@badgerwithagun
Copy link
Author

If anyone comes across this, I solved it.

Like most people using WSL and Docker, I had set docker on WSL to use the Docker For WIndows daemon by default, which uses TLS. I had the following in my ~/.bash_profile (but I guess you might have it in .bashrc or even /etc/profile):

export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://1.2.3.4:2376
export DOCKER_CERT_PATH=/mnt/c/Users/myuser/.docker/machine/machines/default
export DOCKER_MACHINE_NAME=default

I guess DOCKER_TLS_VERIFY is the main issue. I did the following:

export DOCKER_TLS_VERIFY=
export DOCKER_HOST=
terraform apply

And it worked. A permanent solution is just to uncomment the relevant lines in the profile script, but that means docker stops working locally.

@mavogel
Copy link
Contributor

mavogel commented Oct 14, 2019

@badgerwithagun thank you for sharing your solution 🙏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants