Create Terraform Infrastructure with Docker

From wikieduonline
Revision as of 05:13, 15 February 2022 by Chmod15 (talk | contribs) (Created page with " main.tf terraform { required_providers { docker = { source = "kreuzwerker/docker" version = "~> 2.15.0" } } } provider "docker" {} res...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
main.tf

 terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "~> 2.15.0"
    }
  }
}
provider "docker" {}
resource "docker_image" "nginx" {
  name         = "nginx:latest"
  keep_locally = false
}
resource "docker_container" "nginx" {
  image = docker_image.nginx.latest
  name  = "tutorial"
  ports {
    internal = 80
    external = 8000
  }
}

Advertising: