DevOps, Day - 62
Terraform and Docker

💻 Python | Docker | Jenkins | Networking | Git | Linux 💻
Passionate about leveraging technology to drive efficiency and deliver innovative solutions. Proficient in Python development, Docker containerization, Jenkins automation, computer networking, Git version control, and Linux administration. Skilled in collaborating with diverse teams to deliver high-quality software products. Proficient in AWS EC2 instance management and deployment.
Seeking new opportunities to apply my expertise and contribute to impactful projects. Let's connect and explore how we can work together!
Inter-personal Skills:
Communication, Adaptability, Emotional intelligence, Active listening, Collaboration.
Happy To Connect🔗😊
Feel free to reach me out😃@ --> vrishnishreevb531@gmail.com 📬
Terraform needs to be told which provider to use in the automation, hence we need to give the provider name with source and version. For Docker, we can use this block of code in your main.tf
Task-01
- Create a Terraform script with Blocks and Resources, I also added a provider block in it.
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 2.21.0"
}
}
}
provider "docker" {}

Resource
Use resource blocks to define components of your infrastructure. A resource might be a physical or virtual component such as a Docker container, or it can be a logical resource such as a Heroku application.
Resource blocks have two strings before the block: the resource type and the resource name. In this example, the first resource type is docker_image and the name is Nginx.
Task-02
Create a resource Block for an nginx docker image
# Define a Docker image resource block
resource "docker_image" "nginx" {
name = "nginx:latest"
keep_locally = false
}
# Define a Docker container resource block
resource "docker_container" "nginx" {
name = "tutorial"
image = docker_image.nginx.latest
ports {
internal = 8080
external = 90
}
}
terraform init

terraform apply

Check docker the created docker container

check-in browser

Video Course
Terraform can be tricky, so best to use a Free video Course for Terraform here
Thank you so much for reading
Follow me on LinkedIn to see interesting posts like this : )




