Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"One-shot tasks" via docker_container fail with "Error: No such container: xxx" #639

Open
ZauberNerd opened this issue Jul 17, 2024 · 0 comments

Comments

@ZauberNerd
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

Terraform v1.9.2
on linux_amd64
+ provider registry.terraform.io/kreuzwerker/docker v3.0.2

Affected Resource(s)

  • docker_container

Terraform Configuration Files

terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "~> 3.0.2"
    }
  }
}

provider "docker" {}

resource "docker_container" "build-task" {
  image    = "debian:testing"
  name     = "example-build-task"
  # imagine this being a build process on a bind-mounted volume
  command  = ["echo", "hello world"]
  # we want to wait for the build to finish (e.g. to be able to use depends_on)
  attach   = true
  # the build (and thus the container) will finish at some point
  must_run = false
  # we want to clean-up and remove the build container
  rm       = true
}

Debug Output

https://gist.github.com/ZauberNerd/3245880f47e969baffeb0aa58ed2f31c

Panic Output

Expected Behaviour

terraform apply should not fail.

Actual Behaviour

terraform apply fails.

Steps to Reproduce

  1. terraform apply

Important Factoids

The debug log was captured by running terraform in docker (with the hosts docker socket mounted), because I have installed OpenTofu instead of terraform on my host.
But the error occurs with both terraform and opentofu.

References

  • #0000

Workaround

I'm using the local-exec provisioner for now (docker run --rm ...).

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

No branches or pull requests

1 participant