Reputation: 1574
I am trying Terraform as Docker. I have pulled the image from:
I have simple main.tf:
output "greetings" { value = "Hello World!" }
provider "random" {}
Now, in the same dir as main.tf I run:
docker run -i -t hashicorp/terraform:light plan main.tf
as it is suggested on that page. But I get the error:
stat main.tf: no such file or directory
So I guess that I need to create a Dockerfile to create an image including the main.tf, right?
thanks.
Upvotes: 0
Views: 1210
Reputation: 2845
First, you need to make sure that your terraform files are available inside the container. This can be done using volumes as it is shown below
$> docker run -it -v $PWD:/tr-scripts hashicorp/terraform:light plan /tr-scripts/
second, you may need to run init
before the plan
dockerfile example
From hashicorp/terraform:light
COPY ./TR-SCRIPT /tr-scripts
RUN terraform init /tr-scripts
Upvotes: 5