• Input Variables serve as parameters for a Terraform module, so users can customize behavior without editing the source.
  • Output Values are like return values for a Terraform module.
  • Local Values are a convenience feature for assigning a short name to an expression.

Type constraints are created from a mixture of type keywords and type constructors. The supported type keywords are:

  • string
  • number
  • bool

Terraform File:

terraform {

  required_providers {

    docker = {

      source = “terraform-providers/docker”



  required_version = “>= 0.13”


variable  “container_name” {

type = string 


resource “docker_container” “container” {

  image = var.container_name

  name  = “tutorial”


output “Container_ip” {

value = docker_container.container.ip_address


Check the changes using the terraform plan command.

Terraform plan 

To apply those changes use the terraform apply command.

terraform apply

It will wait for user input in our case for the container image.

Task by Trainer:

Task 2: 

  • Create a MySQL container using an input variable.
  • Name container as “mydb”
  • Forward it to port “3306” 
  • Use the environment variable to set MYSQL_ROOT_PASSWORD to mypass.
  • Use Output variable to display container IP.