-
Notifications
You must be signed in to change notification settings - Fork 39
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
Feature request: Build args on docker hub #508
Comments
Together with LABEL, build args is very useful to apply custom metadata to images. For example:
Setting |
Yes, it would be really useful. +404003 |
I've been thinking the same thing since I started using buildargs. It would be perfect if there was a way to set specific buildargs for specific tags on my dockerhub image, instead of having to create separate tags/branches in my git repo. |
This would be even better than #292 |
@yajo note that this is regarding access to set |
Yes, I just meant that #292 could cover the same use cases, but fixing this would be much better for most of those. |
This would make multi-version maintenance of images a lot easier |
This is available in Docker Cloud, which uses the same backend than Hub for autobuilds. The way to do it is to define autobuild env variables, an write a |
Can someone explain the method described by @pchico83? Because the documentation does not mention anything about writing a |
@nalipaz although it is not documented, it is supported (I will open an issue to improve the documentation). For example, if you define an env var called
whose content could be:
Note that the hook is executed using the dockerfile folder as working dir, and |
That is much clearer, thanks @pchico83, and yes it would be very helpful to many I am sure were it documented. Thanks. |
@pchico83, @nalipaz , Can you please provide me an example of how this hooks is used? Do we use the same docker file commands? For example, in hooks/post_checkout, I added ENV UI_BUILD x-1.2.2 But this throws me the following log. |
Yeah, a gist or example project would likely be helpful for this. I will see if I can find time to test and make one although I am not using this feature currently. I opted for using Travis CI to use a make file to pass in params to the build and then push the final image into docker hub. |
@Gurubol You are probably missing the |
Thanks to @pchico83 guidance, I was able to look around and discovered a number of useful pieces of information
Redacted fields contained what looked like keys I assume would be harmless and expired by now, but I'm not sure ;) But the take away is also have access to Hope this helps with this pretty awesome undocumented feature! |
Here is a test image I use to check which hook are triggered when and which variables are available : Check the result of the build here : |
I really need this. I have multiple Dockerfiles because I have multiple distros to support, so they're each in their own folder, meaning they don't have the whole repo in their context, so the repo is cloned during |
@andschwa I prefer to have multiple named Dockerfiles in the root of the repo and then just run |
need this feature for the automatically build, would be really nice. |
Learned this from docker/hub-feedback#508 (comment) and from https://github.com/git-lfs/build-dockers No longer using wget since build.sh is on the same level as the Dockerfile.
Description found in https://docs.docker.com/docker-cloud/builds/advanced/ Kudos to @pchico83 for docker/hub-feedback#508
I think this is the fix and the issue should be closed? |
@edify42 Well it could be closed, but the workaround does not actually supply the requested feature. Right now it is possible to add This naming is very confusing IMO and it should be renamed to And, in addition, we need a Because there is a clear difference between the two: https://vsupalov.com/docker-arg-vs-env/ TL;DR |
2015... and this still isn't available? |
We need to pass the argument `BASE_IMAGE` to docker build in order to specify whether we're building on Debian stretch or buster, but dockerhub's automated builds don't let you do this directly. This is a workaround per [this issue](docker/hub-feedback#508).
since 2015 till 2019/09/26 .. still not available ! :( |
They are available, you just have to use build hooks. |
See my example... |
This should fix raiden-network#5049 In order to build the proper raiden version from `Dockerfile`, we need to pass the intended `RAIDENVERSION` build argument. According to docker/hub-feedback#508 the current way of doing this is via build hook. dockerhub has the `SOURCE_BRANCH` environment variable available, that should translate just fine to the values we want in `RAIDENVERSION`.
This should fix #5049 In order to build the proper raiden version from `Dockerfile`, we need to pass the intended `RAIDENVERSION` build argument. According to docker/hub-feedback#508 the current way of doing this is via build hook. dockerhub has the `SOURCE_BRANCH` environment variable available, that should translate just fine to the values we want in `RAIDENVERSION`.
* As per docker/hub-feedback#508, there is no way to specify build_args to Docker builds on docker hub. The only solution is to have hack using hooks. This works but for different variants, there will be too many different environment variables to be defined.
Does this need to still be open? I see some thumbs down, but https://docs.docker.com/docker-hub/builds/advanced/#override-the-build-phase-to-set-variables actually solves this on Docker Hub. I was able to build an image with
and it worked absolutely fine! No sign of my build arg in the image output, which is the point of build-arg as I understand it. So, how are these To put a finer point on it, https://stackoverflow.com/a/55839775/661659 If you follow this example exactly, but in "step3" except instead of using
agh, maybe not quite secret, I guess this is what you meant:
Is there a way to do this as we intended in Docker at all, or is it a request against nature? I personally really did think this was an impossible request until I found numerous posts describing ARG as a way to put secrets into the build without letting them leak out through the images. But here it is, (at least most of) the secret (edit: yes, you can recover the whole secret and any other ARGs using It looks like they are leaked out through docker history, but not into the container image runtime context. "So I've got that going for me at least, which is nice." TBH this might still be marked as solved, I'm not sure how Docker images can maintain a consistent format if they allow secrets to be used at build time but not included in If you really want to use a secret and then don't include it in the build output, you could use ARG together with a multi-stage build and then squash, but actually I think maybe squash image is still an experimental feature. Thoughts? |
Just wanna check what the current situation is:
But this method also overwrites the whole build command. Which means it also overwrites the --tag,--file, and most importantly --no-cache
|
It's been a while since I looked at this, but I believe By environment variable, I mean it is an environment variable set in the shell that calls In order to manually pass along an environment variable like So instead of saying:
You would want something like
Only then will the environment variable Note: I think this feature request is about adding the ability to specify a value from the webpage dockerhub and have it passed along somehow as a build arg. So the desire of this feature request is to set "stuff" from the webpage and have it set to the docker build arg "FOO", without needing to write your own For now @HarelM , you should be able to accomplish what you want specifically by using a |
@andyneff Thanks for the info! |
I'm laughing because DockerHub... You had one job! Really?.. Why are the key value pair fields sat on the DockerHub auto-build configuration page? This has been open since 2015 and people are confused between setting those key value pairs and the notion of adding build variables via |
Since we can have ARGS on dockerfile, seems right to have them available on auto-builds as also (for having different tags based on the same Dockerfile)
The text was updated successfully, but these errors were encountered: