terraform-provider-docker: Intermittent errors with using SSH
Community Note
- Please vote on this issue by adding a đ reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave â+1â or âme tooâ comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform (and docker Provider) Version
Terraform v1.0.3
on linux_amd64
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/kreuzwerker/docker v2.14.0
+ provider registry.terraform.io/scottwinkler/shell v1.7.7
Affected Resource(s)
docker_container
Debug Output
âˇ
â Error: Unable to read Docker image into resource: unable to pull image yandex/clickhouse-server:20.3.9.70: command [ssh -l username -- 123.123.123.123 docker system dial-stdio] has exited with signal: killed, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
â
â with module.clickhouse.docker_image.clickhouse,
â on modules/clickhouse/main.tf line 23, in resource "docker_image" "clickhouse":
â 23: resource "docker_image" "clickhouse" {
â
âľ
Expected Behaviour
No error.
Actual Behaviour
Intermittent errors with error messages as above.
Steps to Reproduce
Just try to launch 10-15 different containers with different images (kafka, postgres, etc, etc) over SSH. SSH is the most important thing.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 22
- Comments: 40 (13 by maintainers)
Commits related to this issue
- Add integration test for SSH remote connections Uses a Digitalocean Droplet (Docker/Ubuntu) to provide a remote Docker host and verifies that it can successfully create a RemoteImage and run ... — committed to pulumi/pulumi-docker by guineveresaenger a year ago
- Add integration test for SSH remote connections Uses a Digitalocean Droplet (Docker/Ubuntu) to provide a remote Docker host and verifies that it can successfully create a RemoteImage and run ... — committed to pulumi/pulumi-docker by guineveresaenger a year ago
- Explicitly read in SSH config flags to the docker client configuration (#707) * Read in SSH flags to the connection helper to avoid error in Configure * Add integration test for SSH remote connect... — committed to pulumi/pulumi-docker by guineveresaenger 10 months ago
Maintainer here: I am monitoring this issue closely and reading every comment. Under the hood we are simply using the
dockerclient, so any issues from the docker client also appear in this provider. So anyone with that issue, please try out the âdocker sshâ workaround from the comment above.I still have not managed to build a reproducible case myself, thatâs the first thing on my list. I wonât have time in the next 2-3 weeks, but after that hopefully will try to tackle this. Even after building a reproducible case I am not sure whether there will be a single/simple solution for that issue. Letâs seeâŚ
Someone posted a solution on the docker-compose issue that not only works, but also speeds up the deployment since the docker socket is passed through a single socket instead of opening multiple ssh connections.
https://github.com/docker/compose/issues/8544#issuecomment-1060664712
I use it this way in my CICD scripts :
Don´t forget to remove the
host = "ssh:/..."in your terraform configurationThe same error on large deployments, came from version
2.12where it works more slowly and failed with an error connection refused, at2.11there is no error and everything works fast@k2m30 I donât think this issue is related to the server in any way, since downgrading the docker provider version solves the issue.
But while digging into the issue, I found out that the docker-compose community has been facing the exact same issue since May 2021 (which match the very first message of this issue). So during all this time, I blamed this PR âterraform-sdk v2â PR while the bug seems to be more related to the docker client.
The problematic version of the provider bumped to docker client from v20.0.0 to v20.10.5, It may be something to investigate on
@compojoom indeed I do not think the ssh suggestion from above fixes the issue (it merely hides it / alleviates part of it).
Closing bug reports for lack of activity on the project might not be the right way to deal with issuesâŚ
Iâm also commenting on this for the sake of keeping this issue opened. This is a serious issue
This reply tells me that the problem is in using too many SSH connections.
Am I right, @Junkern, @prologic?
UPD Maybe the solution would be simply to introduce an SSH connection pooling proxy?
After testing multiple commit manually, the bug has been introduced when migrating to the terraform-sdk v2 (MR Link) which is a huge MR đ
Same with 2.16, I get
unable to pullwhen there are more than 2 containers to deploy.I reverted to 2.11 and the problem is not present.
Reusing sockets seems to help with the issue in my use case (https://docs.rackspace.com/blog/speeding-up-ssh-session-creation/#:~:text=The ControlMaster option is one,over the same underlying connection.)
Pretty much:
Not clear to me what could have changed (I assume in the vendored docker/cli) - but they do also mention it in their docs: https://docs.docker.com/engine/security/protect-access/#ssh-tips
This is not a fix though, and likely to cause issues.
I donât think this is related to #80. I have been using this docker provider for a year and I started to seeing this error since a few weeks when I try to deploy more than ~10 containers. It appears randomly when too many ssh connections are established. Even with
-parallelism=2, the error still occurr. The terraform debug doesnât provide any useful informations and the stderr is empty as mentioned by @AndreiPashkin.I will try to investigate into this during the next weeks