Skip to content

Instantly share code, notes, and snippets.

@darkn3rd
Created May 30, 2019 02:44
Show Gist options
  • Save darkn3rd/4c276dbe5bbbf15d98e2cd081bc7d38a to your computer and use it in GitHub Desktop.
Save darkn3rd/4c276dbe5bbbf15d98e2cd081bc7d38a to your computer and use it in GitHub Desktop.
Terraform Docker Sample
provider "docker" {}
# declare any input variables
# create docker volume resource
# create docker network resource
# create db container
resource "docker_container" "db" {
name = "db"
image = "mysql:5.7"
restart = "always"
}
# create wordpress container
resource "docker_container" "wordpress" {
name = "wordpress"
image = "wordpress:latest"
restart = "always"
ports = {
internal = "80"
external = "8080"
}
}
@Cinderhaze
Copy link

Cinderhaze commented Nov 9, 2019

you have a typo on line 21 - if I try to run it as is

Error: Unsupported argument

  on example.tf line 31, in resource "docker_container" "wordpress":
  21:   ports = {

An argument named "ports" is not expected here. Did you mean to define a block
of type "ports"?

removing the = to turn it from an assignment into a block allows it to work properly.

@divyaraghavann
Copy link

THANK YOU! this helped me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment