-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provider can't connect to Docker daemon in WSL 2 #44
Comments
I fixed this. And usually I leave a comment when I do. Really disappointed that I didn't though because now I don't remember how I did. xD I think what happened was I misunderstood how Docker is meant to be used from within WSL 2. I installed it in the Linux distro. I didn't use Docker Desktop in Windows (which makes Docker available for use from within WSL 2 as long as Windows programs are on the path - which is the default setting for WSL 2). And I think when I used the installation of Docker that was done from the host side in Windows 10 using Docker Desktop, it worked. |
What a pity. If you find out/remember the steps how to fix it, then please update here and we'll add it to the documentation. |
@mavogel Once I typed it all out, I remembered it. That's exactly what it was. I would consider this issue closed. As far as I know, it's just an issue with how I was using Docker, which of course let to an issue with this provider trying to use Docker. |
Alright, thanks for the update. |
Hi there, sorry for barging in after this one was closed but I can't seem to figure out a solution to this issue. I started from here which was the exact problem I had: hashicorp/terraform-provider-docker#180 But I see that that repo is closed now, for some reason. The solution suggested there, is not working as of today on a fresh installation of terraform and docker. So I decided to try the docker port open instead, even if it's a security issue. I'm just testing locally after all, no big deal. If you think that there will be a better place to post this, please link it for me. I'm following this tutorial: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/gcp-get-started
Despite that, it output an error:
Even if I have the ports open and the docker engine running. I have docker installed and running from the windows host and I already use it successfully while creating images/containers directly with the |
Hi @theCrius , no worries. We're happy to help. Could you update to the latest version |
Hey, thanks for the quick reply. When running
However, I checked the "show terminal" button on the tutorial I was following and noticed that in the sandbox, the commands are working. So I checked the The
So I tried starting from that one and making just some small changes. The final version of the file is this one:
I cleaned up everything except the I guess the problem was this snippet:
But why it was there and it's a problem, I don't know. Is there a way to reach the writers of the tutorial to tell them to update the content? I can do it myself If it's an open source project as well. |
@theCrius I asked internally what's the best way to update this page and will come back to you :) THanks for reporting this. I'm also interested in having the tutorials work |
Good to know @mavogel, let me know if I can help in any way. My office's laptop run on windows so I can run tests if needed. My experience with Terraform is not vast but I'm quite experienced with devops works anyway (dockers, kubernetes, jenkins, etc) so, as much as I can, I'll gladly help. |
@theCrius , here the internal response:
Thanks for reporting the issue, and if you feel contributing to this project let me know :) |
Thanks @mavogel, I had already wrote a feedback specifying the issue the other day. I guessed that that could have been one of the channels anyway :) Have a good weekend! |
I replied in the feedback as well. I just removed |
I had a problem with the lab and found this thread. Every time problem was with this part
I ran docker from Win start menu and after terraform apply I got the error docker Then I start docker with docker run -d -p 80:80 docker/getting-started and after that the protocol became available. The part that docker has be to running is missed in the description of the lab. |
This worked for me as well! |
Hey all, hoping someone can try help. I am having a similar issue with my docker provider not working via Terraform Cloud. I have been able to get this working locally but when I tried Terraform Cloud (in order to setup GitHub actions) I am now getting errors. I am not using GCP and trying to push to docker registry instead, unsure if that matters. I am using v3.0.1 of the plug-in. I have tried to check tcp://localhost without TLS and I have tried to set the host explicitly with no luck.
|
same here, windows 11 using WSL. The problem is, that "http://127.0.0.1:2375/_ping" is not reachable from windows but in the WSL. Not sure if it is a terraform issue in itself. But
|
make sure that the docker is running (use docker ps) before terraform apply. . |
Reconfiguring docker in WSL2 to listen on port 2375 worked for me: |
This issue was originally opened by @mattwelke as hashicorp/terraform-provider-docker#303. It was migrated here as a result of the community provider takeover from @kreuzwerker. The original body of the issue is below.
Terraform Version
Terraform v0.12.29 (using old version intentionally because I'm following a tutorial that references particular modules that don't yet support 0.13)
Affected Resource(s)
n/a
Terraform Configuration Files
versions.tf
:providers.tf
:variables.tf
:terraform.tfvars
:outputs.tf
:main.tf
:Debug Output
Please provider a link to a GitHub Gist containing the complete debug output: https://gist.github.com/mattwelke/ce34d58c1281d49930f81caaa257800e
Panic Output
n/a
Expected Behavior
A docker container being created.
Actual Behavior
An error applying Terraform config when it tried to use the Docker provider.
Steps to Reproduce
docker ps
)terraform apply
Important Factoids
I ensured I had Docker set up to be useable from within WSL 2 first. I was able to run commands like
docker ps
:But then, when running
terraform apply
, it displayed that error, saying it couldn't reach the daemon. I tried using the port2376
instead of2375
in the Terraform config, but that didn't work. I also tried enabling this option in Docker Desktop in Windows:But this also made no difference (even when using port
2375
in the Terraform config).I'm using Ubuntu 20.10 in WSL 2.
References
When troubleshooting, I tried the steps in the issue hashicorp/terraform-provider-docker#210, but it didn't help.
The text was updated successfully, but these errors were encountered: