Reputation: 21
i'm beginner in Terraform.
I tried to install docker image nginx on my local server but i have an issue when i launch the command
terraform plan
Error: Unsupported attribute │ │ on dockernginx.tf line 20, in resource "docker_container" "nginx": │ 20: image = docker_image.nginx.latest │ │ This object has no argument, nested block, or exported attribute named "latest".
there is my code:
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "3.0.2"
}
}
}
provider "docker" {
host = "tcp://${var.ssh_host}:2375"
}
resource "docker_image" "nginx" {
name = "nginx:latest"
}
resource "docker_container" "nginx" {
image = docker_image.nginx.latest
name = "enginecks"
ports {
internal = 80
external = 80
}
}
if someone can help me please ?!
Best regards
I tried to install docker image nginx on my local server but i have an issue when i launch the command
terraform plan
Upvotes: 2
Views: 2519
Reputation: 174
In the resource "docker_container" "nginx", change the image from
image = docker_image.nginx.latest
to
image = docker_image.nginx.image_id
Because the "docker_image" don`t output the attribute "latest", just "image_id".
Upvotes: 4