{"id":24630670,"url":"https://github.com/p4irin/explore_terraform_docker_nginx","last_synced_at":"2026-05-07T23:02:07.987Z","repository":{"id":273605045,"uuid":"920197094","full_name":"p4irin/explore_terraform_docker_nginx","owner":"p4irin","description":"Provision a Docker container running a default setup of nginx with Terraform","archived":false,"fork":false,"pushed_at":"2025-02-12T18:15:22.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T05:43:37.590Z","etag":null,"topics":["docker","explore","nginx","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p4irin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-21T18:22:18.000Z","updated_at":"2025-02-12T18:15:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"63b25dac-6607-4c67-9217-ae0b876473a5","html_url":"https://github.com/p4irin/explore_terraform_docker_nginx","commit_stats":null,"previous_names":["p4irin/explore_terraform_docker_nginx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/p4irin/explore_terraform_docker_nginx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_docker_nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_docker_nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_docker_nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_docker_nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p4irin","download_url":"https://codeload.github.com/p4irin/explore_terraform_docker_nginx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_docker_nginx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32759448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","explore","nginx","terraform"],"created_at":"2025-01-25T07:12:35.946Z","updated_at":"2026-05-07T23:02:07.957Z","avatar_url":"https://github.com/p4irin.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Explore Terraform\n\n Provision and manage a Docker container running a default nginx setup\n\n## Provision resources declared in `main.tf`\n\nInitialize the project: downloads plugin/provider to interact with Docker\n```bash\n$ terraform init\n```\n\nProvision nginx container\n```bash\n$ terraform apply\n```\n\nVerify the image was downloaded\n```bash\n$ docker image ls|grep nginx\n```\n\nVerify the container is running with\n```bash\n$ docker ps|grep nginx\n```\nor by visiting http://localhost:8000 in your browser\n\nShow the state of your infrastructure\n```bash\n$ terraform show\n```\n\nShow a list of managed resources\n```bash\n$ terraform state list\n```\n\n## Change the docker_container resource\n\nChange the external port of the container to 8080\n\n```hcl\nresource \"docker_container\" \"nginx\" {\n  image = docker_image.nginx.image_id\n  name  = \"nginx\"\n\n  ports {\n    internal = 80\n    external = 8080\n  }\n```\n\nApply the resource change. The port of a running container can't be changed. Terraform will destroy the existing container and replace it with a new one.\n\n```bash\n$ terraform apply\n```\n\nVerify the new container's external port is 8080\n\n```bash\n$ docker ps\n```\nor visit http://localhost:8080.\nor\n\n```bash\n$ terraform state show docker_container.nginx\n```\n\n## Use a variable for the container name\n\nRefer to the content of `variables.tf` which declares the `container_name` variable used in `main.tf`.\n\nWith these files and variable declaration in place, applying the configuration\n\n```bash\n$ terraform apply\n...\n```\n\nwil result in a container with the default name `ExampleNginxContainer`. Verify with\n\n```bash\n$ docker ps\n```\n\nWhen applying the config. you can pass a name of your choosing with the `-var` option:\n\n```bash\n$ terraform apply -var \"container_name=ADefaultNginxSetup\"\n```\n### Reference\n\n* [Customize Terraform configuration with variables](https://developer.hashicorp.com/terraform/tutorials/configuration-language/variables)\n\n### Labs\n* [lab](https://kodekloud.com/pages/free-labs/terraform/terraform-variables)\n* [lab](https://kodekloud.com/pages/free-labs/terraform/terraform-variables-2)\n\n## Query and display data\n\nRefer to the file `outputs.tf`. It declares _outputs_ that query/represents the nginx _container id_ and _image id_.\n\nAssuming you already applied your config. including this file you can use/query the output values:\n\n```bash\n$ terraform output\ncontainer_id = \"c0c0742...\"\nimage_id = \"sha256:9bea9f...\"\n```\n\n### Reference\n\n* [Output data from Terraform](https://developer.hashicorp.com/terraform/tutorials/configuration-language/outputs)\n\n### Labs\n\n* [lab](https://kodekloud.com/pages/free-labs/terraform/terraform-output-variables)\n## Destroy provisioned resources\n```bash\n$ terraform destroy\n```\n\nVerify destruction of image and container\n```bash\n$ docker image ls|grep nginx\n$ docker ps|grep nginx\n$ terraform show\n```\n\n## Reference\n\n* [Docker provider documentation](https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs)\n* [Terraform registry](https://registry.terraform.io/)\n* [Terraform](https://developer.hashicorp.com/terraform)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fexplore_terraform_docker_nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp4irin%2Fexplore_terraform_docker_nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fexplore_terraform_docker_nginx/lists"}