Created
March 29, 2018 06:59
-
-
Save derekm1215/f24167614f46f14494f7f10b00b8f24c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "container_name" { | |
description = "Name of container" | |
default = "blog" | |
} | |
variable "image" { | |
description = "image for container" | |
default = "ghost:latest" | |
} | |
variable "int_port" { | |
description = "internal port for container" | |
default = "2368" | |
} | |
variable "ext_port" { | |
description = "external port for container" | |
default = "80" | |
} | |
# Download the latest Ghost Image | |
resource "docker_image" "image_id" { | |
name = "${var.image}" | |
} | |
# Start the Container | |
resource "docker_container" "container_id" { | |
name = "${var.container_name}" | |
image = "${docker_image.image_id.latest}" | |
ports { | |
internal = "${var.int_port}" | |
external = "${var.ext_port}" | |
} | |
} | |
#Output the IP Address of the Container | |
output "IP Address" { | |
value = "${docker_container.container_id.ip_address}" | |
} | |
output "container_name" { | |
value = "${docker_container.container_id.name}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment