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

Unable to pre-fetch an image when using build-args in FROM #3238

Closed
AB-xdev opened this issue Sep 16, 2020 · 7 comments · Fixed by #6119
Closed

Unable to pre-fetch an image when using build-args in FROM #3238

AB-xdev opened this issue Sep 16, 2020 · 7 comments · Fixed by #6119

Comments

@AB-xdev
Copy link
Contributor

AB-xdev commented Sep 16, 2020

We are using the following:

new ImageFromDockerfile()
	.withDockerfile(Paths.get("Dockerfile"))
...

Dockerfile

ARG tag=latest
FROM maven:3-openjdk-11 AS build-env
# Build
FROM domain.com/package/image:${tag}
# Copy builded stuff into container

This throws an exception, as it trys to pre-fetch an image:

11:25:48 INFO  [ducttape-0] [ilder.ImageFromDockerfile] Pre-emptively checking local images for 'domain.com/package/image:${tag}', referenced via a Dockerfile. If not available, it will be pulled.  
11:25:48 ERROR [tc-okhttp-stream-1066222696] [nc.ResultCallbackTemplate] Error during callback  
com.github.dockerjava.api.exception.BadRequestException: {"message":"invalid reference format"}

	at com.github.dockerjava.okhttp.OkHttpInvocationBuilder.execute(OkHttpInvocationBuilder.java:283)
	at com.github.dockerjava.okhttp.OkHttpInvocationBuilder.lambda$executeAndStream$4(OkHttpInvocationBuilder.java:317)
	at java.base/java.lang.Thread.run(Thread.java:834)
11:25:48 WARN  [ducttape-0] [ilder.ImageFromDockerfile] Unable to pre-fetch an image (domain.com/package/image:${tag}) depended upon by Dockerfile - image build will continue but may fail. Exception message was: {"message":"invalid reference format"}

It would be nice

  • if the code which pre-fetches/pulls the dependencies would automatically consider the use of args and either uses them to download the image or simply ignores it
  • OR if there is an option to disable the pre-fetching/pulling
@stale
Copy link

stale bot commented Dec 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Dec 19, 2020
@AB-xdev
Copy link
Contributor Author

AB-xdev commented Jan 7, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open...

It would be great if the issue stays open, because the problem still exists.

@stale stale bot removed the stale label Jan 7, 2021
@jarebudev
Copy link

I've also come across this issue when trying to move our tests to using .withDockerfile(Paths.get("Dockerfile")) so we could use .dockerignore files to minimise our build context.

I'll try and contribute a PR if i can get around to it

@npepinpe
Copy link

npepinpe commented Nov 1, 2022

Would be great to see this resolved. Is anything special missing from the PR? I was willing to contribute one as well, but seeing as how there's one opened already, I'd rather see it merged 👍

@Donnerbart
Copy link
Contributor

We still face this issue. Can someone please have a look at #6119 to get this fixed?

@AB-xdev
Copy link
Contributor Author

AB-xdev commented Apr 23, 2024

So the problem is still sticking around after 3.5years...

We fixed this a few years ago internally for one of our non public projects and now open sourced these fixes in our own implementation of ImageBuilder.
Feel free to use it in the meantime :)

@Donnerbart
Copy link
Contributor

I'm happy to rebase my pending PR if someone will finally review it. We also have workarounds in place for this, that I'd really like to get rid of.

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