Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Image argument after v2.6.0 always replaces resources (mismatch between image name vs sha image id) #294

Open
johnlane opened this issue Sep 27, 2020 · 2 comments

Comments

@johnlane
Copy link

johnlane commented Sep 27, 2020

There is a difference between the handling of the image argument of v2.6.0 and v2.7.2.

The image specification shown below works with the 2.6.0 Docker provider but not with version 2.7.2.

resource "docker_container" "portainer" {
  image   = "portainer/portainer:1.23.0"
  ...

The documentation now shows having a reference to an image resource:

   image = "${docker_image.ubuntu.latest}"

and configuring that image resource to specify the image name.

With 2.7.2 there is a perpetual mismatch between the image name spcified in the config and the image id that terraform plan and apply identifies.

I can't find any documentation covering this breaking change between versions, I don't know if this break is intentional or something that would be fixed. I see many examples illustrating the succinct way of referencing an image that works in version 2.6.0. It would be good if specifying the image directly in image continued to work rather than requiring an additional image resource block containing the image name.

If the form that worked in 2.6.0 is not supported any more than an error during plan or apply to prevent its use would make this clear. Currently it's accepted as valid but causes resource replacement on every apply.

Terraform Version

Terraform 0.13.3 with Docker provider 2.6.0 and 2.7.2

Affected Resource(s)

docker_container

Expected Behavior

The resource should be matched with previous state so unnecessary changes are not made.

Actual Behavior

The resource is detected as a change because the given image value is matched against SHA and therefore is always detected as a change, requiring replacement of the resource.

Steps to Reproduce

  1. terraform apply

References

hashicorp/terraform#26382

Also #291 is similar.

@Mayeu
Copy link

Mayeu commented Oct 10, 2020

I have a similar situation with 2.7.2 but the replacement only happens once, and weirdly enough, not with all images.

I'm running TF on macOS and here is my versions.tf:

terraform {
  required_providers {
    docker = {
      source  = "terraform-providers/docker"
      version = "~> 2.7.2"
    }
  }
  required_version = ">= 0.13"
}

@rucciva
Copy link

rucciva commented Oct 16, 2020

For me, who is using terraform 0.11.4 (trying to move to 0.12), upgrading to v2.6.0 also result in similar
situation. i can only upgrade to v2.5.0 safely without recreating all my docker container

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants