Skip to content

iqtheengineer/terraform-docker-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn



Terraform Deployment - Docker Container with Nginx Web Server

Automating With Terraform
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure. The cloud computing tool assists in building, modifying, and versioning infrastructure in a secure and efficient manner.

In this project I crafted a Terraform file to automate the process of creating a Docker container that runs a Nginx web server image.

(back to top)

Built With

(back to top)

Getting Started

These are instructions for Windows Users. To gather instruction for other OS please visit: https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/gcp-get-started

To get started you would want to make sure you have the following utlities installed:

  • Terraform
  • Docker
  • WSL2

Steps

Create a directory named learn-terraform-docker-container:

mkdir learn-terraform-docker-container

Then navigate into it:

cd learn-terraform-docker-container

Paste the following Terraform configuration into a file and name it main.tf:

terraform {
required_providers {
  docker = {
    source  = "kreuzwerker/docker"
    version = ">= 2.16.0"
  }
}
}

provider "docker" {
}

resource "docker_image" "nginx" {
name         = "nginx:latest"
keep_locally = false
}

resource "docker_container" "nginx" {
image = docker_image.nginx.latest
name  = "tutorial"
ports {
  internal = 80
  external = 8000
}
}

Then initialize the project:

terraform init

And finally provision and push the configuration:

terraform apply

If all goes well you should see the Nginx container running of localhost:800 or by running docker ps:

After that is done, be sure to stop the container and destroy the Nginx webserver:

terraform destroy

Usage

For examples, please refer to the Documentation

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Project Link: https://github.com/iqtheengineer/gcp-terraform-project

(back to top)

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages