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
130 stars 92 forks source link

Terraform destroy not work on docker container #280

Open ghost opened 4 years ago

ghost commented 4 years ago

This issue was originally opened by @greenmns as hashicorp/terraform#25552. It was migrated here as a result of the provider split. The original body of the issue is below.


I have a terrafom file with name main.tf that resource is only docker_container my terraform version is Terraform v0.12.28

main.tf file is:

provider "docker" {
}

#data "docker_registry_image" "baresip" {
#   name          =     "registry.gitlab.com/greenmns/test"
#}

#resource "docker_image" "baresip" {
# name           =     "registry.gitlab.com/greenmns/test"
# pull_triggers  =     ["${data.docker_registry_image.baresip.sha256_digest}"]
#}

resource "docker_container" "baresipcallee" {
  name           =     "baresipcallee"
  image          =     "registry.gitlab.com/greenmns/test"
  command        =     ["1"]
  rm             =     true
}

image registry.gitlab.com/greenmns/test is locally in my computer.

when i run terraform apply to generate a container i saw with docker ps my container is up but when i run terraform destroy container test is run and it didn't destory I think this is a buge of terraform

suzuki-shunsuke commented 4 years ago

https://www.terraform.io/docs/providers/docker/r/container.html#image

image - (Required, string) The ID of the image to back this container. The easiest way to get this value is to use the docker_image resource as is shown in the example above.

image should be not registry.gitlab.com/greenmns/test but image ID of registry.gitlab.com/greenmns/test.

andrewbulin commented 4 years ago

I'm not sure the image information is related, but I confirm I'm having a similar issue with terraform destroy if the docker_container flag rm = true is set. See also issue https://github.com/terraform-providers/terraform-provider-docker/issues/163