hashicorp / terraform-provider-docker

As part of our introduction to self-service publishing in the Terraform Registry, this copy of the provider has been archived, and ownership has been transferred to active maintainers in the community. Please see the new location on the Terraform Registry: https://registry.terraform.io/providers/kreuzwerker/docker/latest
https://registry.terraform.io/providers/kreuzwerker/docker/latest
Mozilla Public License 2.0
132 stars 92 forks source link

Unable to remove Docker image: image is referenced in multiple repositories #301

Open stoically opened 4 years ago

stoically commented 4 years ago

Terraform Version

Terraform v0.13.3

Affected Resource(s)

Terraform Configuration Files

data "docker_registry_image" "traefik" {
  name = "traefik:latest"
}

resource "docker_image" "traefik" {
  name          = data.docker_registry_image.traefik.name
  pull_triggers = [data.docker_registry_image.traefik.sha256_digest]
}

Expected Behavior

Should always silently upgrade the image / container

Actual Behavior

Error: Unable to remove Docker image: Error response from daemon: conflict: unable to delete 1a3f0281f41e (must be forced) - image is referenced in multiple repositories

Steps to Reproduce

Unfortunately not sure how to reproduce

Notes

Would it be safe to always force-remove images?

simon-wessel commented 4 years ago

This occurred for me when I had multiple tags referring to the same image (e.g. nginx:latest and nginx:1.19.3). I worked around the issue by manually force-deleting the image with docker rmi -f [image id]. You should probably stop other containers using that specific image first though.