If you use kreuzwerker/docker as the Terraform Docker provider, you might have seen a similar deprecated attribute warning here below since version 2.13.0.

│ Warning: Deprecated attribute
│   on main.tf line 18, in resource "docker_container" "name":
│   18:   image = docker_image.[image_name].latest
terraform {
│ The attribute "latest" is deprecated. Refer to the provider documentation for details.
│ (and one more similar warning elsewhere)

While both documetations of the provider and Terraform tutorial were still using the latest attribute in their examples.

resource "docker_container" "name" {
  image = docker_image.[image_name].latest
  name  = "container_name"
  ports {

It’s bizarre that someone told you that the latest attribute should not be used any longer, but they also told you the latest attribute is still the best practice.


Finally, as version 2.21.0 was released, kreuzwerker/docker gave us a new attribute as a solution, image_id. Official Documents

And you can reference a docker_image in the way below:

# Start a container
resource "docker_container" "ubuntu" {
  name  = "foo"
  image = docker_image.ubuntu.image_id

# Find the latest Ubuntu precise image.
resource "docker_image" "ubuntu" {
  name = "ubuntu:precise"

So, update your docker provider now, use the new attribute, and hope they won’t change them that easily again.