terraform-provider-docker icon indicating copy to clipboard operation
terraform-provider-docker copied to clipboard

README example errors out (darwin/intel)

Open wbadart opened this issue 1 year ago • 0 comments

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.3.0
on darwin_amd64
+ provider registry.terraform.io/kreuzwerker/docker v2.22.0

Affected Resource(s)

  • docker_image

Terraform Configuration Files

terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "2.22.0"
    }
  }
}

provider "docker" {}

resource "docker_image" "nginx" {
  name = "nginx:latest"
}

Debug Output

https://gist.github.com/wbadart/533690a9cb2cc66458df979c93d9795a

Panic Output

n/a

Expected Behaviour

Expected the image resource to load successfully for use in later container resources.

I originally had a more complete config file that combined snippets from the Hashi tutorial and the README in this repo (incorporating the docker_registry_image data source and docker_conatiner resource) but I think I've narrowed down the issue to just the docker_image resource.

Actual Behaviour

The minimal config provided above errors out with:

Terraform will perform the following actions:
  # docker_image.nginx will be created
  + resource "docker_image" "nginx" {
      + id          = (known after apply)
      + image_id    = (known after apply)
      + latest      = (known after apply)
      + name        = "nginx:latest"
      + output      = (known after apply)
      + repo_digest = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
docker_image.nginx: Creating...
╷
│ Error: Unable to read Docker image into resource: unable to find or pull image nginx:latest
│
│   with docker_image.nginx,
│   on main.tf line 12, in resource "docker_image" "nginx":
│   12: resource "docker_image" "nginx" {
│
╵

(See gist above for full debug output.)

One interesting note is that prior to applying main.tf, running docker images confirms I have no nginx:latest locally, but after applying main.tf, even though it errors out, docker images shows nginx:latest.

Steps to Reproduce

mkdir scratch
cd scratch
cat <<EOF > main.tf
terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "2.22.0"
    }
  }
}

provider "docker" {}

resource "docker_image" "nginx" {
  name = "nginx:latest"
}
EOF
terraform init
terraform apply -auto-approve

Important Factoids

Fairly vanilla Docker Desktop setup on Mac (Monterey, Intel).

$ docker --version
Docker version 20.10.17, build 100c701

$ uname -a
Darwin C02F30WCML87 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64

Docker daemon config:

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  }
}

References

  • Found some tangentially related discussion in #262, though I'm not accessing Docker via SSH
  • Same error message as #52, though I'm not using the digest to specify the image

Thanks for your consideration! (And I apologize if I'm missing something silly here.)

wbadart avatar Sep 28 '22 17:09 wbadart