Open dk-ebeisecker opened 1 year ago
I know it's abit late and you probably have solved the issue as well, but for others, all the post-processor
s block, should reside inside a post-processors {}
(at least for the OP's case) to be applied sequentially, like this:
post-processors {
post-processor "docker-tag" {
repository = "${var.container_registry}/my-base-image"
tags = [local.container_tag]
}
post-processor "docker-push" {
login = true
login_server = var.container_registry
login_username = var.container_registry_username
login_password = var.container_registry_password
}
}
otherwise, the tag no found error will occure.
I know it's abit late and you probably have solved the issue as well, but for others, all the
post-processor
s block, should reside inside apost-processors {}
(at least for the OP's case) to be applied sequentially, like this:post-processors { post-processor "docker-tag" { repository = "${var.container_registry}/my-base-image" tags = [local.container_tag] } post-processor "docker-push" { login = true login_server = var.container_registry login_username = var.container_registry_username login_password = var.container_registry_password } }
otherwise, the tag no found error will occure.
This Packer documentation seems to indicate that putting each post-processor
in a post-processors
block isn't necessary?
from my experience, when running docker-push
post-processor, things are probably a bit diffrent (compare to docker-export), where it will try to push right after the build, without having a tag
and will fail eventually - that's what my understanding. Without clubing together tag and push within a post-processors
block, I always end up with no-tag-found error.
I still have trouble when trying to push multiple images to Artifactory via the docker-push post-processor, with the error:
Pushing: <my_registry><my_image>:<container tag>
The push refers to repository [<my_registry><my_image>]
An image does not exist locally with the tag: <my_registry><my_image>
The image name matches, however it seems like somewhere it's thinking the image name is the tag.
I also am logged in to the Artifactory instance, and I'm able to push with the docker push
command.
Overview of the Issue
When using the
post-processor "docker-push"
post-processor with Private repository location, Username & password settings, the push command appears to try to push the image to Dockerhub instead.Reproduction Steps
Run a packer build using the Docker source + tag & push post-processors
Plugin and Packer version
1.8.6_windows_amd64
packer-plugin-docker_v1.0.8_x5.0_windows_amd64.exe
Simplified Packer Buildfile
Operating system and Environment details
Windows Server 2022 x64
Log Fragments and crash.log files
==> BaseWindowContainer.docker.winservercore: Running post-processor: (type docker-tag) -- [INFO] (telemetry) Starting post-processor docker-tag BaseWindowContainer.docker.winservercore (docker-tag): Tagging image: sha256:ddbc57331955ad9b07dc8708ad24eb51f1fadb8b3fde730f7c7afa9ef1a355b4 BaseWindowContainer.docker.winservercore (docker-tag): Repository: my-container.registery.com/my-base-image:0.1.0 ==> BaseWindowContainer.docker.winservercore: Running post-processor: (type docker-push) -- 22-Apr-2023 12:53:27 | 2023/04/22 16:53:27 Flagging to keep original artifact from post-processor 'docker-tag' 22-Apr-2023 12:53:27 | 2023/04/22 16:53:27 [INFO] (telemetry) Starting post-processor docker-push 22-Apr-2023 12:53:27 | BaseWindowContainer.docker.winservercore (docker-push): Creating temporary Docker configuration directory 22-Apr-2023 12:53:27 | BaseWindowContainer.docker.winservercore (docker-push): Logging in... 22-Apr-2023 12:53:27 | 2023/04/22 16:53:27 packer-plugin-docker_v1.0.8_x5.0_windows_amd64.exe plugin: 2023/04/22 16:53:27 Executing: C:\Program Files\Docker\docker.exe [--config C:\Users\User1\AppData\Local\Temp\packer2090728066 login -u reg_user--password-stdin my-container.registery.com] 22-Apr-2023 12:53:27 | BaseWindowContainer.docker.winservercore (docker-push): WARNING! Your password will be stored unencrypted in C:\Users\User1\AppData\Local\Temp\packer2090728066\config.json. 22-Apr-2023 12:53:27 | BaseWindowContainer.docker.winservercore (docker-push): Configure a credential helper to remove this warning. See 22-Apr-2023 12:53:27 | BaseWindowContainer.docker.winservercore (docker-push): Login Succeeded 22-Apr-2023 12:53:27 | BaseWindowContainer.docker.winservercore (docker-push): https://docs.docker.com/engine/reference/commandline/login/#credentials-store 22-Apr-2023 12:53:27 | BaseWindowContainer.docker.winservercore (docker-push): Pushing: sha256:ddbc57331955ad9b07dc8708ad24eb51f1fadb8b3fde730f7c7afa9ef1a355b4 22-Apr-2023 12:53:28 | 2023/04/22 16:53:28 packer-plugin-docker_v1.0.8_x5.0_windows_amd64.exe plugin: 2023/04/22 16:53:28 Executing: C:\Program Files\Docker\docker.exe [--config C:\Users\User1\AppData\Local\Temp\packer2090728066 push sha256:ddbc57331955ad9b07dc8708ad24eb51f1fadb8b3fde730f7c7afa9ef1a355b4] 22-Apr-2023 12:53:28 | BaseWindowContainer.docker.winservercore (docker-push): An image does not exist locally with the tag: sha256 22-Apr-2023 12:53:28 | BaseWindowContainer.docker.winservercore (docker-push): The push refers to repository [docker.io/library/sha256] 22-Apr-2023 12:53:28 | BaseWindowContainer.docker.winservercore (docker-push): Logging out...