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

Publishing a docker image to a private registry fails without authentication #28844

Closed
shahamit opened this issue Nov 29, 2021 · 4 comments
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@shahamit
Copy link

I have a private docker registry setup on our local infrastructure. It is configured without any authentication. I am trying to build and push the docker image to this registry with the spring-boot:build-image command but I get an error "Invalid Docker publish registry configuration, either token or username/password must be provided". My maven plugin configuration looks like below

                            <configuration>
					<image>
						<name><vm-name>:5000/dev/my-spring-boot-app:v1</name>
						<publish>true</publish>
					</image>
					<docker>
						<publishRegistry>
							<url>http://<vm-name>:5000</url>
						</publishRegistry>
					</docker>
				</configuration>

This is intentional as the code indicates. Could someone please guide me how to push my docker image to an unauthenticated private docker registry?

Thanks

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 29, 2021
@scottfrederick
Copy link
Contributor

scottfrederick commented Nov 29, 2021

Thanks for getting in touch. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. This is a question that would be better suited to Stack Overflow.

The only reason to provide the <docker><publishRegistry> block is to provide authentication for the registry. Including the registry in the image name provided by <image><name> and setting <publish>true</publish> is sufficient to get the image published to the registry without authentication.

@scottfrederick scottfrederick added for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 29, 2021
@sean-duffy-gmex
Copy link

The only reason to provide the <docker><publishRegistry> block is to provide authentication for the registry. Including the registry in the image name provided by <image><name> and setting <publish>true</publish> is sufficient to get the image published to the registry without authentication.

This does not seem to be the case, when running with publish set to true and no publishRegistry block I get:

Publishing an image requires docker.publishRegistry to be configured

Is there no way to publish to an unauthenticated registry using this plugin currently?

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Jul 7, 2022
@scottfrederick
Copy link
Contributor

This does not seem to be the case...

@sean-duffy-gmex You are correct, the docker.publishRegistry configuration is required when publish is set to true. What I said in my comment above is true for docker.builderRegistry but not true for docker.publishRegistry. I'm not sure what I was thinking when I said that.

when running with publish set to true and no publishRegistry block I get...

This explicit check is done because the Docker Engine API requires an authentication header to be sent in an image-push request, and will give a 400 BAD REQUEST error if authentication is not provided.

It should be possible for us to default the publishRegistry to empty values and effectively send a dummy auth header instead of requiring a publishRegistry to be configured explicitly. I'll re-open the issue so others on the team can comment on that idea and what version we would want to make a change like that in.

Is there no way to publish to an unauthenticated registry using this plugin currently?

It is likely that you can configure docker.publishRegistry with any value for the username and password fields to make this work. An auth header will be built and sent to the Docker Engine API and likely ignored by the registry.

@scottfrederick scottfrederick added status: waiting-for-triage An issue we've not yet triaged and removed for: stackoverflow A question that's better suited to stackoverflow.com labels Jul 18, 2022
@wilkinsona
Copy link
Member

I think we could consider it to be a bug that you can't easily push to a private registry that doesn't require authentication. Where we fix it will depend on how risky it might be. It sounds quite low risk as I think we'd only be changing the behavior for something that doesn't work at the moment. 2.6.x doesn't feel unreasonable to me.

@wilkinsona wilkinsona added type: bug A general bug and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Jul 20, 2022
@wilkinsona wilkinsona added this to the 2.6.x milestone Jul 20, 2022
@scottfrederick scottfrederick self-assigned this Jul 20, 2022
@scottfrederick scottfrederick changed the title Pushing docker image on a private registry fails with an error Publishing a docker image to a private registry fails without authentication Jul 20, 2022
scottfrederick added a commit that referenced this issue Jul 20, 2022
@scottfrederick scottfrederick modified the milestones: 2.6.x, 2.6.10 Jul 20, 2022
scottfrederick added a commit that referenced this issue Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants