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

Terraform destroy not work on docker container #280

Open
ghost opened this issue Jul 13, 2020 · 2 comments
Open

Terraform destroy not work on docker container #280

ghost opened this issue Jul 13, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 13, 2020

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
Copy link
Contributor

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
Copy link

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 #163

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

2 participants