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

buildx push ignores <repository> tag in build #1597

Closed
tadgh opened this issue Sep 2, 2022 · 1 comment · Fixed by #1629
Closed

buildx push ignores <repository> tag in build #1597

tadgh opened this issue Sep 2, 2022 · 1 comment · Fixed by #1629

Comments

@tadgh
Copy link
Contributor

tadgh commented Sep 2, 2022

I believe the <registry> tag is ignored when using <buildx>. Below are 2 separate configurations, the former attempts to uplaod to dockerhub, the latter successfully pushes to my private registry.

This setup attempts to push to dockerhub.

	<configuration>
			<registry>my-registry.com</registry>
			<images>
				<image>
					<name>my-image</name>
					<alias>my-image</alias>
					<build>
						<buildx>
							<platforms>
								<platform>linux/arm64</platform>
								<platform>linux/amd64</platform>
							</platforms>
						</buildx>
						<contextDir>${project.basedir}/target/dockercontext</contextDir>
						<tags>
							<tag>${project.version}</>
						</tags>
						<args>
							<TARFILE>dockerimage.tar.gz</TARFILE>
						</args>
					</build>
				</image>
			</images>
			<verbose>true</verbose>
		</configuration>

Using the push phase, this is the command that is generated:

docker
--config /path/to/docker buildx build
--progress=plain
--builder maven --platform linux/arm64,linux/amd64
--tag my-image:2022.11.PRE 
--push --file=/path/to/Dockerfile /path/to/tmp/docker-build

However if i instead prefix the image name with the registry, buildx respects it:

	<configuration>
			<registry>i-am-ignored.com</registry>
			<images>
				<image>
					<name>my-regsitry.com/my-image</name>
					<alias>my-image</alias>
					<build>
						<buildx>
							<platforms>
								<platform>linux/arm64</platform>
								<platform>linux/amd64</platform>
							</platforms>
						</buildx>
						<contextDir>${project.basedir}/target/dockercontext</contextDir>
						<tags>
							<tag>${project.version}</tag>
						</tags>
						<args>
							<TARFILE>dockerimage.tar.gz</TARFILE>
						</args>
					</build>
				</image>
			</images>
			<verbose>true</verbose>
		</configuration>

This setup generates the following buildx command, which does what i want it to do (e.g. push to my own registry).

docker --config /path/to/docker buildx build
--progress=plain
--builder maven 
--platform linux/arm64,linux/amd64  
--tag my-registry.com/my-image:2022.11
--push --file=/path/to/Dockerfile /path/to/tmp/docker-build

This tag allows buildx to upload to my own repository. I suppose all I can expect here is for the to be sneakily prefixed onto the tag during a buildx build, if present.

I've got it working, but just figure this would be a nice bit of syntactic sugar for people converting from non buildx builds to buildx builds.

Cheers

@tadgh
Copy link
Contributor Author

tadgh commented Jan 12, 2023

Cheers, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant