Please help docker-push to AWS ECS private registry

1,012 views
Skip to first unread message

p

unread,
Sep 2, 2016, 1:04:26 PM9/2/16
to Packer
Hello,

Could someone please help me configure Packer to be able to do a docker-push to an AWS ECS private registry? Let me explain the problem.

The AWS ECS private registry uses a password that expires every twelve hours. An AWS tool allows one to get a new password when the password expires. In the packer file where the post-processor docker-push is defined exists a field called login_password. It is this field that uses that 12 hour password. I am looking for a way to automatically update that password in the packer file possibly by interpolating a variable to fill in the login_password field. I can't seem to find a way to do this.

While I can simply write shell scripts using regex to target the field, I was hoping there would be an elegant way built into Packer to accomplish this? Thank you.

P

Rickard von Essen

unread,
Sep 3, 2016, 8:13:17 AM9/3/16
to Packer
This works for me:

eval $(aws --profile=packer-demo ecr get-login); packer build ecr_docker.json

With the following template - ecr_docker.json:
{
"builders": [
{
"type": "docker",
"image": "alpine",
"run_command": ["-d", "-i", "-t", "{{.Image}}", "/bin/ash"],
"commit": true
}
],
"post-processors": [
[
{
"type": "docker-tag",
"repository": "965990659467.dkr.ecr.eu-central-1.amazonaws.com/packer-test",
"tag": "latest"
},
{
"type": "docker-push",
"login": false,
"login_server": "https://965990659467.dkr.ecr.eu-central-1.amazonaws.com/packer-test"
}
]
]
}

But it should be fairly easy to extend docker-push postprocessor to support ECR. PR's are welcome.

Rickard von Essen

unread,
Sep 4, 2016, 9:12:07 AM9/4/16
to Packer
I added "native" support for ECR, see https://github.com/mitchellh/packer/pull/3856

p

unread,
Sep 6, 2016, 1:28:21 PM9/6/16
to Packer
Thanks for this advice. I figured out this exact same thing. So, my initial requirements have been met. Now it's time for me to figure out the pull portion. Thank you.

Rickard von Essen

unread,
Sep 6, 2016, 2:45:15 PM9/6/16
to packe...@googlegroups.com
This works for me:

eval $(aws --profile=packer-demo ecr get-login); packer build ecr_docker.json

With the following template - ecr_docker.json:
{
  "builders": [
    {
      "type": "docker",
      "image": "alpine",
      "run_command": ["-d", "-i", "-t", "{{.Image}}", "/bin/ash"],
      "commit": true
    }
  ],
  "post-processors": [
    [
      {
        "type": "docker-tag",
        "tag": "latest"
      },
      {
        "type": "docker-push",
        "login": false,
      }
    ]
  ]
}


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/a93a7a06-eed0-44b4-9432-63f30b30f805%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rickard von Essen

unread,
Sep 6, 2016, 2:45:15 PM9/6/16
to packe...@googlegroups.com
But it should be fairly easy to extend docker-push postprocessor to support ECR. PR's are welcome.

Rickard von Essen

unread,
Sep 6, 2016, 2:45:21 PM9/6/16
to packe...@googlegroups.com
I added "native" support for ECR, see https://github.com/mitchellh/packer/pull/3856
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages