Skip to content

Instantly share code, notes, and snippets.

@derekm1215
Created March 29, 2018 07:03
Show Gist options
  • Save derekm1215/619ff3df138311b50b5e70dfb7315b94 to your computer and use it in GitHub Desktop.
Save derekm1215/619ff3df138311b50b5e70dfb7315b94 to your computer and use it in GitHub Desktop.
# 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}"
}
#Output the IP Address of the Container
output "ip" {
value = "${docker_container.container_id.ip_address}"
}
output "container_name" {
value = "${docker_container.container_id.name}"
}
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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment