Code Monkey home page Code Monkey logo

Comments (5)

devashish-patel avatar devashish-patel commented on August 28, 2024

Hi @gdrapp,

In the given snippet, the login_server argument is missing https:// and repository name. Please add https:// and the repo name to the login_server argument in your post-processor and everything should work fine.

Example:

    post-processor "docker-push" {
      ecr_login    = true
      aws_profile  = "default"
      login_server = "https://317215053986.dkr.ecr.us-east-2.amazonaws.com/<YOUR_PRIVATE_REPO_NAME>"
    }

Full example template:

packer {
  required_plugins {
    docker = {
      version = ">= 1.0.7"
      source  = "github.com/hashicorp/docker"
    }
  }
}

source "docker" "ubuntu-bionic" {
  image  = "ubuntu:bionic"
  commit = true
}

build {
  name = "docker-push-ecr-private"
  sources = [
    "source.docker.ubuntu-bionic"
  ]

  post-processors {
    post-processor "docker-tag" {
      repository = "746700064644.dkr.ecr.us-east-1.amazonaws.com/private_dev_hc_pkr_dkr_test_1"
      tags       = ["latest"]
    }

    post-processor "docker-push" {
      ecr_login    = true
      aws_profile  = "default"
      login_server = "https://746700064644.dkr.ecr.us-east-1.amazonaws.com/private_dev_hc_pkr_dkr_test_1"
    }
  }
}

This should fix the problem otherwise feel free to reach out!

Thanks!

from packer-plugin-docker.

axway-dpal avatar axway-dpal commented on August 28, 2024

Hi @gdrapp,

In the given snippet, the login_server argument is missing https:// and repository name. Please add https:// and the repo name to the login_server argument in your post-processor and everything should work fine.

Example:

    post-processor "docker-push" {
      ecr_login    = true
      aws_profile  = "default"
      login_server = "https://317215053986.dkr.ecr.us-east-2.amazonaws.com/<YOUR_PRIVATE_REPO_NAME>"
    }

Full example template:

packer {
  required_plugins {
    docker = {
      version = ">= 1.0.7"
      source  = "github.com/hashicorp/docker"
    }
  }
}

source "docker" "ubuntu-bionic" {
  image  = "ubuntu:bionic"
  commit = true
}

build {
  name = "docker-push-ecr-private"
  sources = [
    "source.docker.ubuntu-bionic"
  ]

  post-processors {
    post-processor "docker-tag" {
      repository = "746700064644.dkr.ecr.us-east-1.amazonaws.com/private_dev_hc_pkr_dkr_test_1"
      tags       = ["latest"]
    }

    post-processor "docker-push" {
      ecr_login    = true
      aws_profile  = "default"
      login_server = "https://746700064644.dkr.ecr.us-east-1.amazonaws.com/private_dev_hc_pkr_dkr_test_1"
    }
  }
}

This should fix the problem otherwise feel free to reach out!

Thanks!

isn't this is a breaking change?

from packer-plugin-docker.

axway-dpal avatar axway-dpal commented on August 28, 2024

Another Interesting case for me.
When I use private repo from us-east-1 like xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com
Sample Source Code:

variable "registry" {
  type    = string
  default = "xxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com"
}
source "docker" "base" {
  image  = "python:3.9-alpine"
  commit = true
  changes = [
    "ENTRYPOINT /bin/bash",
    "ENV BASH_ENV /home/gitlab/.bashrc",
    "USER gitlab"
  ]
  run_command = var.run_cmd
}

build {

  sources = ["source.docker.base"]

  provisioner "ansible" {
    playbook_file = "prepare.yml"
    user          = "root"
  }

  provisioner "ansible" {
    playbook_file        = "main.yml"
    user                 = "gitlab"
    galaxy_file          = "requirements.yml"
    galaxy_force_install = true
    extra_arguments      = ["--extra-vars", "target=all"]
  }

  post-processors {
    post-processor "docker-tag" {
      repository = local.repo
      tags       = [formatdate("DDMMMYYYYhhmm", timestamp()), "latest"]
    }

    post-processor "docker-push" {
      ecr_login    = true
      login_server = var.registry
    }
  }
}

Docker push works fine

But when I use another region like eu-west-3 like xxxxxxxx.dkr.ecr.eu-west-3.amazonaws.com docker push fails with same error.

from packer-plugin-docker.

devashish-patel avatar devashish-patel commented on August 28, 2024

Hi, @axway-dpal and @gdrapp. We have fixed the bug related to this in v1.0.8. Please update the plugin and everything should work fine as it used to be (aka no need to prefix the login_server value with https://!

Please feel free to reopen this issue, if you have questions or facing any issues.

Thanks for the patience!

from packer-plugin-docker.

axway-dpal avatar axway-dpal commented on August 28, 2024

Thanks a lot @devashish-patel, I will try it asap.

from packer-plugin-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.