Difference between revisions of "Create Terraform Infrastructure with Docker"

From wikieduonline
Jump to navigation Jump to search
(Created page with " main.tf terraform { required_providers { docker = { source = "kreuzwerker/docker" version = "~> 2.15.0" } } } provider "docker" {} res...")
 
Line 1: Line 1:
 
  main.tf
 
  main.tf
 
   
 
   
  terraform {
+
 
 +
<pre> terraform {
 
   required_providers {
 
   required_providers {
 
     docker = {
 
     docker = {
Line 25: Line 26:
 
   }
 
   }
 
  }
 
  }
 +
</pre>

Revision as of 05:14, 15 February 2022

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: