kreuzwerker / terraform-provider-docker

Terraform Docker provider
Mozilla Public License 2.0
609 stars 187 forks source link

Error during pushing image to GCP Artifact Registry, Unable to create image, image not found: unable to get digest: Got bad response from registry: 405 Method Not Allowed #621

Open antoniomazzeo opened 4 months ago

antoniomazzeo commented 4 months ago

Community Note

Terraform (and docker Provider) Version

Tested with Terraform version 1.8.4 Docker provider at version v3.0.2

Affected Resource(s)

Terraform Configuration Files

resource "docker_image" "lib-check" {
  name = "${var.region}-docker.pkg.dev/${var.project_id}/${var.project_id}-docker-registry/lib-check:latest"
  build {
    context = "./cicd"
    dockerfile = "lib-check-Dockerfile"
  }
  triggers = {
    dir_sha1 = sha1(join("", [for f in fileset(path.module, "cicd/lib-check-Dockerfile") : filesha1(f)]))
  }
  depends_on = [
    google_artifact_registry_repository.docker-registry
  ]
}

resource "docker_registry_image" "lib-check-image" {
  name          = docker_image.lib-check.name
  keep_remotely = true
}

Debug Output

(https://gist.github.com/antoniomazzeo/3066b66c381b660765eef0819bad224c)

Expected Behaviour

Docker image should be pushed without errors

Actual Behaviour

The Docker image is correctly pushed to the GCP Artifact Registry, but the terraform provider gives the error "Unable to create image, image not found: unable to get digest: Got bad response from registry: 405 Method Not Allowed" trying to get image digest. Seems like GCP Artifact Registry is rejecting the HEAD http verb while getting the image digest (data_source_docker_registry_image.go), changing it to GET, everything works as expected, but I don't know if it still works for other registries as well.

Steps to Reproduce

  1. terraform apply
MoisesSDelmoro commented 2 months ago

same problem here