Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
592 views
in Technique[技术] by (71.8m points)

docker - terraform: "Error: Could not load plugin"

Running a terraform plan command with the docker image of hashicorp results in this error:

 $ docker run -it -v `pwd`:/terrascripts  hashicorp/terraform plan /terrascripts
Unable to find image 'hashicorp/terraform:latest' locally
latest: Pulling from hashicorp/terraform
Digest: sha256:eab63752545a0295eedc1318da1d293126cce4689bcd4b139afe816da3f6fffb
Status: Downloaded newer image for hashicorp/terraform:latest

Error: Could not load plugin


Plugin reinitialization required. Please run "terraform init".

Plugins are external binaries that Terraform uses to access and manipulate
resources. The configuration provided requires plugins which can't be located,
don't satisfy the version constraints, or are otherwise incompatible.

Terraform automatically discovers provider requirements from your
configuration, including providers used in child modules. To see the
requirements and constraints, run "terraform providers".

Failed to instantiate provider "registry.terraform.io/hashicorp/aws" to obtain
schema: unknown provider "registry.terraform.io/hashicorp/aws"

Looks like it is similar to this issue. I am using workspaces to refer to different environments. And it only happens when using terraform with the docker image. When using the binary, it works as expected.

Is there a way to overcome this problem when using the docker image hashicorp/terraform?

question from:https://stackoverflow.com/questions/65882461/terraform-error-could-not-load-plugin

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can try with setting up working directory to terrascripts using -w flag:

init

docker run -it -v `pwd`:/terrascripts -w /terrascripts  hashicorp/terraform init

plan

docker run -it -v `pwd`:/terrascripts -w /terrascripts  hashicorp/terraform plan

Depending on your setup you may need to work on this more to provide valid aws credentials.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...