简体   繁体   中英

How can I pass ulimit parameters to a Docker with Terraform?

I'm trying to setup elasticsearch cluster in Docker with Terraform. Docker compose file containing some ulimit definitions on containers:

ulimits:
  memlock:
    soft: -1
    hard: -1

But I didn't found any documentation how to do it with Terraform.

The terraform docker provider does not currently support ulimits. I have created a PR to add support here .

In the meantime, you can install install the branch, by cloning my fork, running go build && cp terraform-provider-docker $HOME/.terraform.d/plugins/

You can then pass a ulimit block to your container like so

provider "docker" {}

resource "docker_image" "elasticsearch" {
  name = "elasticsearch:latest"
}

resource "docker_container" "elasticsearch" {
  image = "${docker_image.elasticsearch.latest}"
  name  = "elasticsearch"

  ports {
    internal = 9200
    external = 9200
  }

  ulimit {
    name = "memlock"
    soft = 100
    hard = 200
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM