Create vm from terraform container

Wanted to create vm/resources in vsphere via terraform container. Following are the commands which I am running and getting Error: error setting up new vSphere SOAP client: Post “https://myvsphere.server.com/sdk”: dial tcp xxx.xxx.xx.xx:443: connect: no route to host

docker run -v pwd:/workspace -w /workspace hashicorp/terraform init

Initializing the backend…
Initializing provider plugins…
Reusing previous version of hashicorp/vsphere from the dependency lock file
Using previously-installed hashicorp/vsphere v2.3.1
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running “terraform plan” to see
any changes that are required for your infrastructure. All Terraform commands should now work.

If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.

docker run -v pwd:/workspace -w /workspace hashicorp/terraform plan -input=false -var-file=my-location.tfvars -var “vm_name=test” -var “vsphere_user=my-user@vsphere.local” -var “vsphere_password=Test@1234”

Error: error setting up new vSphere SOAP client: Post “https://myvsphere.server.com/sdk”: dial tcp xxx.xxx.xx.xx:443: connect: no route to host

│ with provider[“Terraform Registry”],

│ on main.tf line 2, in provider “vsphere”:

│ 2: provider “vsphere” {

main.tf

provider “vsphere” {
user = var.vsphere_user
password = var.vsphere_password
vsphere_server = var.vsphere_server
allow_unverified_ssl = true
}

That error is saying there is no network connectivity between the container and the vmware host. You will need to take a look at the routing table to see what there is and what is missing. Instead of using a Terraform container try using a general purpose Linux container (e.g. Ubuntu) where you can install networking tools to help diagnosis.