Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_registry_image can't build image #395

Closed
azatsafin opened this issue Jul 4, 2022 · 3 comments
Closed

docker_registry_image can't build image #395

azatsafin opened this issue Jul 4, 2022 · 3 comments
Labels
bug Something isn't working r/registry_image

Comments

@azatsafin
Copy link

azatsafin commented Jul 4, 2022

Hello, I am faced with the problem of creating docker images and push it to AWS ECR. After some debugging hours I found that it works with provider version <=2.12.0 and not working with newer versions.

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.1.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.21.0
+ provider registry.terraform.io/kreuzwerker/docker v2.17.0

Your version of Terraform is out of date! The latest version
is 1.2.4. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

  • docker_registry_image

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 4.8.0"
    }
    docker = {
      source  = "kreuzwerker/docker"
      version = "2.17.0"
    }
  }
  required_version = "1.1.7"
}

data "aws_ecr_authorization_token" "token" {}
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

provider "docker" {
  registry_auth {
    address  = format("%v.dkr.ecr.%v.amazonaws.com", data.aws_caller_identity.current.account_id, data.aws_region.current.name)
    username = data.aws_ecr_authorization_token.token.user_name
    password = data.aws_ecr_authorization_token.token.password
  }
}

resource "docker_registry_image" "helloworld" {
  name = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/test_docker_provider:no_bug"

  build {
    context = "/abs_path_to_folder_with_dockerfile"
  }
}

Debug Output

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # docker_registry_image.helloworld will be created
  + resource "docker_registry_image" "helloworld" {
      + id                   = (known after apply)
      + insecure_skip_verify = false
      + keep_remotely        = false
      + name                 = "024975173233.dkr.ecr.eu-central-1.amazonaws.com/test_docker_provider:bug"
      + sha256_digest        = (known after apply)

      + build {
          + context    = "/abs_path_to_folder_with_dockerfile:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
          + dockerfile = "Dockerfile"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
docker_registry_image.helloworld: Creating...
╷
│ Error: Error building docker image: Error response from daemon: Cannot locate specified Dockerfile: Dockerfile
│ 
│   with docker_registry_image.helloworld,
│   on local_docker_image.tf line 27, in resource "docker_registry_image" "helloworld":
│   27: resource "docker_registry_image" "helloworld" {
│ 
╵

Expected Behaviour

Build docker image and push it

Actual Behaviour

Steps to Reproduce

  1. terraform init --upgrade
  2. terraform apply

Gist Link

Terraform log file

@Junkern
Copy link
Contributor

Junkern commented Jul 8, 2022

Thanks for opening an issue!

We will soon release a new version with some fixes concerning the docker_registry_image resource (including #398)

The new release might fix your issue. If not, we will dig deeper :)

@Junkern Junkern added the bug Something isn't working label Jul 8, 2022
@Junkern
Copy link
Contributor

Junkern commented Jul 11, 2022

@azatsafin we just released v2.18.0. Can you try if that release fixes your problem?

If not: Could you double check the abs_path_to_folder_with_dockerfile folder? Is there a Dockerfile in there?
Feel also free to paste the contents of the folder (ls -ahl) in a gist and post it here, so I can have a better understand what is happening

@azatsafin
Copy link
Author

@Junkern , thank you for your effort, version 2.18.0 solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working r/registry_image
Projects
None yet
Development

No branches or pull requests

2 participants