terraform-provider-docker
terraform-provider-docker copied to clipboard
Misleading error message when creating `docker_image` fails for client-related reason
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 v0.14.5
+ provider registry.terraform.io/hashicorp/aws v2.70.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/kreuzwerker/docker v2.11.0
Affected Resource(s)
docker_image
Terraform Configuration Files
Doesn't really matter but:
resource "docker_image" "remote_backend" {
depends_on = [null_resource.push_backend_image]
name = "${aws_ecr_repository.backend.repository_url}:${var.backend_version}"
pull_triggers = [docker_image.local_backend.name]
keep_locally = true
}
Debug Output
https://gist.github.com/michcio1234/e54f38b68f1e740bbb9c2e4272a1f033
Panic Output
None.
Expected Behaviour
Plugin should have exited with a proper error. It should pass the error message obtained from Docker client, i.e.
"failed to register layer: Error processing tar file(exit status 1): write ...: no space left on device"
Actual Behaviour
Plugin exited with error Unable to read Docker image into resource: Unable to find or pull image, suggesting that the error lies somewhere upstream, e.g. that the image doesn't exist in the registry.
Steps to Reproduce
- Make a TF script with
docker_imageresource - Configure the provider to connect to a machine which is short on disk space so that the image cannot be pulled
terraform apply
Important Factoids
My docker provider controls docker client on a remote machine in AWS. It's that remote machine which ran out of space.
References
None
I checked your debug output.
Error: Unable to read Docker image into resource: Unable to find or pull image <REDACTED>
https://github.com/kreuzwerker/terraform-provider-docker/blob/6b0f977735dbc2ff99faa9278f4d51f2bf077b02/internal/provider/resource_docker_image_funcs.go#L72 https://github.com/kreuzwerker/terraform-provider-docker/blob/6b0f977735dbc2ff99faa9278f4d51f2bf077b02/internal/provider/resource_docker_image_funcs.go#L305
The following log means client.ImagePull doesn't return an error, so it's difficult to return an error you expect.
[DEBUG] pulled image <REDACTED>: {"status":"Pulling from <REDACTED>","id":"0.2.3.2"}
https://github.com/kreuzwerker/terraform-provider-docker/blob/6b0f977735dbc2ff99faa9278f4d51f2bf077b02/internal/provider/resource_docker_image_funcs.go#L216-L229
This issue is stale because it has been open 60 days with no activity.
Remove stale label or comment or this will be closed in 7 days.
If you don't want this issue to be closed, please set the label pinned.
This issue is stale because it has been open 60 days with no activity.
Remove stale label or comment or this will be closed in 7 days.
If you don't want this issue to be closed, please set the label pinned.
Closing this. We have improved the error logging in the past months and, as @suzuki-shunsuke pointed out, we cannot easily access the logs of the docker client itself (especially when we are accessing a remote docker host)