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
Preserve environment variables from the parent image on dockerTools.buildImage #87253
Conversation
@grahamc might also be qualified to review this |
Nice! Agree re. handling |
I looked at old PRs and found this from 2018! #37760. |
Sorry @bjornfor , I missed that. You are right, it's almost the same with this one. I read the discussion there, and I still think merging this PR is worthwhile. I guess that was the final decision on that PR anyway, just the author has lost interest. Also, one thing worth mentioning is that the inheritance of other variables (volumes, labels etc) is not that simple, because as far as I can see there are subtle nuances between the way they are inherited (eg. moby/moby#5147). So, I think the proper solution would either:
So, in short I still think this PR is useful alone (as the original one). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GrahamcOfBorg test docker-tools
Tests locally passed. |
Motivation for this change
When building the Docker images with
docker build
, environment variables from the parent is inherited to the child images. This was not the case withdockerTools.buildImage
, since it discards the parent configuration when building the child image. This behaviour is a bit inconvenient since that pattern is widely used.This PR fetches the environment variables from the parent image and injects to the childs configuration. I also extended the NixOS tests to test this behaviour.
Still this is less than ideal, since the environment variables is not the only thing which should be inherited from the parents. Cmd, entrypoint, user, working directory, labels, volumes are also inherited, but unfortunately all in slightly different ways; and I think trying to replicate all that behavior will be costly. So, we can currently only handle environment variables and implement the others only when necessary.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)