terraform init
terraform plan -out tfconfig.tfplan
terraform apply
docker ps
terraform show
Last active
December 14, 2019 03:34
-
-
Save gkhays/7546e9a1e0d0274a518eea3b856fded7 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
ghays@DESKTOP-AQA8MFG:/d/Users/ghays/poc/terraform-nginx$ terraform plan -out config.tfplan | |
Refreshing Terraform state in-memory prior to plan... | |
The refreshed state will be used to calculate this plan, but will not be | |
persisted to local or remote state storage. | |
------------------------------------------------------------------------ | |
An execution plan has been generated and is shown below. | |
Resource actions are indicated with the following symbols: | |
+ create | |
Terraform will perform the following actions: | |
# docker_container.nginx-server will be created | |
+ resource "docker_container" "nginx-server" { | |
+ attach = false | |
+ bridge = (known after apply) | |
+ container_logs = (known after apply) | |
+ exit_code = (known after apply) | |
+ gateway = (known after apply) | |
+ id = (known after apply) | |
+ image = (known after apply) | |
+ ip_address = (known after apply) | |
+ ip_prefix_length = (known after apply) | |
+ log_driver = "json-file" | |
+ logs = false | |
+ must_run = true | |
+ name = "nginx-server" | |
+ network_data = (known after apply) | |
+ read_only = false | |
+ restart = "no" | |
+ rm = false | |
+ start = true | |
+ ports { | |
+ external = (known after apply) | |
+ internal = 80 | |
+ ip = "0.0.0.0" | |
+ protocol = "tcp" | |
} | |
+ volumes { | |
+ container_path = "/usr/share/nginx/html" | |
+ host_path = "/home/scrapbook/tutorial/www" | |
+ read_only = true | |
} | |
} | |
# docker_image.nginx will be created | |
+ resource "docker_image" "nginx" { | |
+ id = (known after apply) | |
+ latest = (known after apply) | |
+ name = "nginx:1.11-alpine" | |
} | |
Plan: 2 to add, 0 to change, 0 to destroy. | |
Warning: Interpolation-only expressions are deprecated | |
on config.tf line 9, in resource "docker_container" "nginx-server": | |
9: image = "${docker_image.nginx.latest}" | |
Terraform 0.11 and earlier required all non-constant expressions to be | |
provided via interpolation syntax, but this pattern is now deprecated. To | |
silence this warning, remove the "${ sequence from the start and the }" | |
sequence from the end of this expression, leaving just the inner expression. | |
Template interpolation syntax is still used to construct strings from | |
expressions when the template includes multiple interpolation sequences or a | |
mixture of literal strings and interpolations. This deprecation applies only | |
to templates that consist entirely of a single interpolation sequence. | |
------------------------------------------------------------------------ | |
This plan was saved to: config.tfplan | |
To perform exactly these actions, run the following command to apply: | |
terraform apply "config.tfplan" | |
ghays@DESKTOP-AQA8MFG:/d/Users/ghays/poc/terraform-nginx$ terraform apply | |
An execution plan has been generated and is shown below. | |
Resource actions are indicated with the following symbols: | |
+ create | |
Terraform will perform the following actions: | |
# docker_container.nginx-server will be created | |
+ resource "docker_container" "nginx-server" { | |
+ attach = false | |
+ bridge = (known after apply) | |
+ container_logs = (known after apply) | |
+ exit_code = (known after apply) | |
+ gateway = (known after apply) | |
+ id = (known after apply) | |
+ image = (known after apply) | |
+ ip_address = (known after apply) | |
+ ip_prefix_length = (known after apply) | |
+ log_driver = "json-file" | |
+ logs = false | |
+ must_run = true | |
+ name = "nginx-server" | |
+ network_data = (known after apply) | |
+ read_only = false | |
+ restart = "no" | |
+ rm = false | |
+ start = true | |
+ ports { | |
+ external = (known after apply) | |
+ internal = 80 | |
+ ip = "0.0.0.0" | |
+ protocol = "tcp" | |
} | |
+ volumes { | |
+ container_path = "/usr/share/nginx/html" | |
+ host_path = "/home/scrapbook/tutorial/www" | |
+ read_only = true | |
} | |
} | |
# docker_image.nginx will be created | |
+ resource "docker_image" "nginx" { | |
+ id = (known after apply) | |
+ latest = (known after apply) | |
+ name = "nginx:1.11-alpine" | |
} | |
Plan: 2 to add, 0 to change, 0 to destroy. | |
Warning: Interpolation-only expressions are deprecated | |
on config.tf line 9, in resource "docker_container" "nginx-server": | |
9: image = "${docker_image.nginx.latest}" | |
Terraform 0.11 and earlier required all non-constant expressions to be | |
provided via interpolation syntax, but this pattern is now deprecated. To | |
silence this warning, remove the "${ sequence from the start and the }" | |
sequence from the end of this expression, leaving just the inner expression. | |
Template interpolation syntax is still used to construct strings from | |
expressions when the template includes multiple interpolation sequences or a | |
mixture of literal strings and interpolations. This deprecation applies only | |
to templates that consist entirely of a single interpolation sequence. | |
Do you want to perform these actions? | |
Terraform will perform the actions described above. | |
Only 'yes' will be accepted to approve. | |
Enter a value: yes | |
docker_image.nginx: Creating... | |
docker_image.nginx: Creation complete after 3s [id=sha256:bedece1f06cc142829698e6ba8f04d7f92e7f1b94b985e14b65f55e6ae4858c2nginx:1.11-alpine] | |
docker_container.nginx-server: Creating... | |
docker_container.nginx-server: Creation complete after 0s [id=649ff1eb6ce7f879fb2ce36b42f3a9a3b8f6473f7b6803af8c30a19e07902339] | |
Apply complete! Resources: 2 added, 0 changed, 0 destroyed. | |
ghays@DESKTOP-AQA8MFG:/d/Users/ghays/poc/terraform-nginx$ docker ps | |
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES | |
649ff1eb6ce7 bedece1f06cc "nginx -g 'daemon of…" 6 seconds ago Up 5 seconds 443/tcp, 0.0.0.0:32768->80/tcp nginx-server | |
ghays@DESKTOP-AQA8MFG:/d/Users/ghays/poc/terraform-nginx$ terraform show | |
# docker_container.nginx-server: | |
resource "docker_container" "nginx-server" { | |
attach = false | |
gateway = "172.17.0.1" | |
id = "649ff1eb6ce7f879fb2ce36b42f3a9a3b8f6473f7b6803af8c30a19e07902339" | |
image = "sha256:bedece1f06cc142829698e6ba8f04d7f92e7f1b94b985e14b65f55e6ae4858c2" | |
ip_address = "172.17.0.2" | |
ip_prefix_length = 16 | |
log_driver = "json-file" | |
logs = false | |
must_run = true | |
name = "nginx-server" | |
network_data = [ | |
{ | |
gateway = "172.17.0.1" | |
ip_address = "172.17.0.2" | |
ip_prefix_length = 16 | |
network_name = "bridge" | |
}, | |
] | |
read_only = false | |
restart = "no" | |
rm = false | |
start = true | |
ports { | |
external = 32768 | |
internal = 80 | |
ip = "0.0.0.0" | |
protocol = "tcp" | |
} | |
volumes { | |
container_path = "/usr/share/nginx/html" | |
host_path = "/home/scrapbook/tutorial/www" | |
read_only = true | |
} | |
} | |
# docker_image.nginx: | |
resource "docker_image" "nginx" { | |
id = "sha256:bedece1f06cc142829698e6ba8f04d7f92e7f1b94b985e14b65f55e6ae4858c2nginx:1.11-alpine" | |
latest = "sha256:bedece1f06cc142829698e6ba8f04d7f92e7f1b94b985e14b65f55e6ae4858c2" | |
name = "nginx:1.11-alpine" | |
} |
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
{ | |
"version": 4, | |
"terraform_version": "0.12.18", | |
"serial": 3, | |
"lineage": "19f1ff15-e162-930b-de65-0f521fb9045d", | |
"outputs": {}, | |
"resources": [ | |
{ | |
"mode": "managed", | |
"type": "docker_container", | |
"name": "nginx-server", | |
"provider": "provider.docker", | |
"instances": [ | |
{ | |
"schema_version": 1, | |
"attributes": { | |
"attach": false, | |
"bridge": "", | |
"capabilities": [], | |
"command": null, | |
"container_logs": null, | |
"cpu_set": null, | |
"cpu_shares": null, | |
"destroy_grace_seconds": null, | |
"devices": [], | |
"dns": null, | |
"dns_opts": null, | |
"dns_search": null, | |
"domainname": null, | |
"entrypoint": null, | |
"env": null, | |
"exit_code": null, | |
"gateway": "172.17.0.1", | |
"group_add": null, | |
"healthcheck": [], | |
"host": [], | |
"hostname": null, | |
"id": "649ff1eb6ce7f879fb2ce36b42f3a9a3b8f6473f7b6803af8c30a19e07902339", | |
"image": "sha256:bedece1f06cc142829698e6ba8f04d7f92e7f1b94b985e14b65f55e6ae4858c2", | |
"ip_address": "172.17.0.2", | |
"ip_prefix_length": 16, | |
"ipc_mode": null, | |
"labels": null, | |
"links": null, | |
"log_driver": "json-file", | |
"log_opts": null, | |
"logs": false, | |
"max_retry_count": null, | |
"memory": null, | |
"memory_swap": null, | |
"mounts": [], | |
"must_run": true, | |
"name": "nginx-server", | |
"network_alias": null, | |
"network_data": [ | |
{ | |
"gateway": "172.17.0.1", | |
"ip_address": "172.17.0.2", | |
"ip_prefix_length": 16, | |
"network_name": "bridge" | |
} | |
], | |
"network_mode": null, | |
"networks": null, | |
"networks_advanced": [], | |
"pid_mode": null, | |
"ports": [ | |
{ | |
"external": 32768, | |
"internal": 80, | |
"ip": "0.0.0.0", | |
"protocol": "tcp" | |
} | |
], | |
"privileged": null, | |
"publish_all_ports": null, | |
"read_only": false, | |
"restart": "no", | |
"rm": false, | |
"shm_size": null, | |
"start": true, | |
"sysctls": null, | |
"tmpfs": null, | |
"ulimit": [], | |
"upload": [], | |
"user": null, | |
"userns_mode": null, | |
"volumes": [ | |
{ | |
"container_path": "/usr/share/nginx/html", | |
"from_container": "", | |
"host_path": "/home/scrapbook/tutorial/www", | |
"read_only": true, | |
"volume_name": "" | |
} | |
], | |
"working_dir": null | |
}, | |
"private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", | |
"dependencies": [ | |
"docker_image.nginx" | |
] | |
} | |
] | |
}, | |
{ | |
"mode": "managed", | |
"type": "docker_image", | |
"name": "nginx", | |
"provider": "provider.docker", | |
"instances": [ | |
{ | |
"schema_version": 0, | |
"attributes": { | |
"id": "sha256:bedece1f06cc142829698e6ba8f04d7f92e7f1b94b985e14b65f55e6ae4858c2nginx:1.11-alpine", | |
"keep_locally": null, | |
"latest": "sha256:bedece1f06cc142829698e6ba8f04d7f92e7f1b94b985e14b65f55e6ae4858c2", | |
"name": "nginx:1.11-alpine", | |
"pull_trigger": null, | |
"pull_triggers": null | |
}, | |
"private": "bnVsbA==" | |
} | |
] | |
} | |
] | |
} |
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
provider "docker" { | |
host = "tcp://localhost:2375/" | |
} | |
resource "docker_image" "nginx" { | |
name = "nginx:1.11-alpine" | |
} | |
resource "docker_container" "nginx-server" { | |
name = "nginx-server" | |
image = "${docker_image.nginx.latest}" | |
ports { | |
internal = 80 | |
} | |
volumes { | |
container_path = "/usr/share/nginx/html" | |
host_path = "/home/scrapbook/tutorial/www" | |
read_only = true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment