Dan
Dan

Reputation: 307

How to save docker logs in terraform

I have this terraform config:

locals {
  service_set = toset(distinct(flatten([for _, v in flatten(fileset(path.module, "../services/**")) : basename(dirname(v))])))
}

resource "docker_image" "service" {
  for_each = local.service_set
  name         = "${each.key}:latest"
  keep_locally = true
}

resource "docker_container" "service" {
  for_each = local.service_set
  image = each.key
  name  = each.key

  attach = true
  logs = true

  env = [
    "Version=local",
  ]

  depends_on = [
    docker_container.mongo,
    docker_container.minio,
    docker_container.rabbitmq,
  ]
}

I'm trying to diagnose why my docker command isn't getting environment variables but for this I have to see the stdout and stderr of the container.

I set logs to true but I can't see where it gets saved too. What is the correct way to save the docker stdout and stderr to a file?

Upvotes: 0

Views: 223

Answers (0)

Related Questions