Skip to content

Legacy error after update from docker 3.0.2 -> 3.6.2: cannot locate Dockerfile #835

@mrstexx

Description

@mrstexx

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

Terraform v1.14.3
on windows_amd64

  • provider registry.terraform.io/hashicorp/archive v2.7.1
  • provider registry.terraform.io/hashicorp/aws v5.100.0
  • provider registry.terraform.io/hashicorp/local v2.6.1
  • provider registry.terraform.io/hashicorp/null v3.2.4
  • provider registry.terraform.io/hashicorp/random v3.7.2
  • provider registry.terraform.io/kreuzwerker/docker v3.6.2

Affected Resource(s)

  • docker_image

Terraform Configuration Files

terraform {
  required_providers {
    docker = {
      source  = "kreuzwerker/docker"
      version = "3.6.2"
    }
  }
}

# ... other config ...

resource "docker_image" "test1" {
  name = local.image_name

  build {
    # build from root directory because Docker has to copy ZIP file with source code
    context    = path.root
    dockerfile = "${path.module}/lambda/container_resources/Dockerfile.test1"
    platform   = "linux/amd64"
    no_cache   = true
  }

  depends_on = [module.test1.archive_base64sha256]

  triggers = {
    dockerfile   = filesha1("${path.module}/container_resources/Dockerfile.test1")
    requirements = filesha1("${path.module}/container_resources/requirements.test1.txt")
    source       = module.test1.archive_base64sha256
  }
}

Actual Behaviour

Error is returned:

Error: Error running legacy build: failed to read dockerfile: open lambda\container_resources\Dockerfile.test1: no such file or directory 

with module.lambda.docker_image.test1, on lambda\test1.tf line 52, in resource "docker_image" "test1":
52: resource "docker_image" "test1" {

What has been actually changed in the regard of context/dockerfile configuration?

I am able to build my docker image from the root folder by running:

docker buildx build -f "lambda/container_resources/Dockerfile.test1" --no-cache .

Steps to Reproduce

  1. terraform apply

Important Factoids

Running on Windows 11 via Docker Desktop

This used to work on docker 3.0.2 but after updating to 3.6.2, legacy error is returned. The update was needed to solve the minimum docker engine API version 1.44 error. I tried with 3.3.0 as well (which is supposed the first version that solved docker compatibility issue).

Metadata

Metadata

Assignees

No one assigned

    Labels

    r/imageRelates to the image resource

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions