terraform-provider-docker: "Error: container exited immediately"

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.1.7 on darwin_amd64 (downloaded binary today). Docker version 20.10.13, build a224086

Affected Resource(s)

  • docker_container

Terraform Configuration Files

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

provider "docker" {}

# web_nfs is a local image generated via Packer.
# It is definitely recognised during plan.
variable "image_nfs" {
  description = "Image for nfs"
  default     = "ubuntu:web_nfs"
}

resource "docker_image" "nfs" {
  name = var.image_nfs
}

resource "docker_container" "nfs" {
  name  = "nfs"
  image = var.image_nfs
}

Debug Output

(https://gist.github.com/MrBenGriffin/d8234d2478758055b88aeafab91b7f68)

Expected Behaviour

It would be nice to see an active container that doesn’t immediately quit.

Actual Behaviour

“Error: container exited immediately”

Steps to Reproduce

Use Mac OS; download the code. Create a docker image (probably vanilla ubuntu focal will be fine - but I haven’t logged in, and that might be a thing).

  1. terraform apply -auto-approve

Important Factoids

Nothing remarkable.

References

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 24 (1 by maintainers)

Most upvoted comments

Closing because it is resolved

https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs/resources/container

Or you may use tty.

e.g.

resource "docker_container" "ubuntu" {
  name  = "foo"
  image = docker_image.ubuntu.latest
  tty   = true
}

resource "docker_image" "ubuntu" {
  name = "ubuntu:precise"
}