-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
docker: do not import configuration from the base image #27634
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
Conversation
@@ -434,6 +434,8 @@ rec { | |||
if [[ -n "$fromImage" ]]; then | |||
echo "Unpacking base image..." | |||
tar -C image -xpf "$fromImage" | |||
# Do not import the base image configuration | |||
rm -f image/*.json |
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.
I think it should be enough to delete the manifest.json
. Which is new since docker/moby image spec v1.2.
The problem is that the manifest.json
describes which layers should be used and buildImage
doesn’t create such a file.
So it definitely makes sense to not import the manifest.json
from the base image 👍. I don’t think it is necessary to delete all json files.
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.
For instance, this is the structure of the image of ubuntu + bash:
tar -tf /nix/store/91vm2lng91f313bnngi87qg3grxynjk0-docker-image-bashOnUbuntu.tar.gz
./
./ef590a0764fab1ffa7a6b08499de5033937c003a283af521371b69a8e72a11bd/
./ef590a0764fab1ffa7a6b08499de5033937c003a283af521371b69a8e72a11bd/layer.tar
./ef590a0764fab1ffa7a6b08499de5033937c003a283af521371b69a8e72a11bd/VERSION
./ef590a0764fab1ffa7a6b08499de5033937c003a283af521371b69a8e72a11bd/json
./1fdb68b6ffa4ad4ae4bfacdbfd6595ef9128d0379eb1a6b36470ac1ec547e40a/
./1fdb68b6ffa4ad4ae4bfacdbfd6595ef9128d0379eb1a6b36470ac1ec547e40a/layer.tar
./1fdb68b6ffa4ad4ae4bfacdbfd6595ef9128d0379eb1a6b36470ac1ec547e40a/VERSION
./1fdb68b6ffa4ad4ae4bfacdbfd6595ef9128d0379eb1a6b36470ac1ec547e40a/json
./54333f1de4ed2730bea18e49605b2ea8f8a2689db213ece94db6ccbc8cf279a6.json
./repositories
./7dd07830e2ffed07a198f014fa9c272d2ca898a9dce00919e0662db7635e80fd/
./7dd07830e2ffed07a198f014fa9c272d2ca898a9dce00919e0662db7635e80fd/layer.tar
./7dd07830e2ffed07a198f014fa9c272d2ca898a9dce00919e0662db7635e80fd/VERSION
./7dd07830e2ffed07a198f014fa9c272d2ca898a9dce00919e0662db7635e80fd/json
./b72351754cb42e486d4b35699b73170a9e7560001abe727de5ea376adcb66c8b/
./b72351754cb42e486d4b35699b73170a9e7560001abe727de5ea376adcb66c8b/layer.tar
./b72351754cb42e486d4b35699b73170a9e7560001abe727de5ea376adcb66c8b/VERSION
./b72351754cb42e486d4b35699b73170a9e7560001abe727de5ea376adcb66c8b/json
./5c0fae2698664beefe0c37cf9815bc8173afc87965bec5455dd4addbb2d23847/
./5c0fae2698664beefe0c37cf9815bc8173afc87965bec5455dd4addbb2d23847/layer.tar
./5c0fae2698664beefe0c37cf9815bc8173afc87965bec5455dd4addbb2d23847/VERSION
./5c0fae2698664beefe0c37cf9815bc8173afc87965bec5455dd4addbb2d23847/json
./manifest.json
./c4dd515170301a4220cf3006bd541bb22dd4bddebe0297f8cd42e28c2667d8ef/
./c4dd515170301a4220cf3006bd541bb22dd4bddebe0297f8cd42e28c2667d8ef/layer.tar
./c4dd515170301a4220cf3006bd541bb22dd4bddebe0297f8cd42e28c2667d8ef/VERSION
./c4dd515170301a4220cf3006bd541bb22dd4bddebe0297f8cd42e28c2667d8ef/json
What would be deleted by this patch is the file 54333f1de4ed2730bea18e49605b2ea8f8a2689db213ece94db6ccbc8cf279a6.json
.
But the file manifest.json
is also wrong since it is inherited from the base image.
So, I think both of these files could be deleted.
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.
Yes, the manifest.json
should be definitely deleted. The other file is the image config of the parent image, which could be (accordingly to the spec) optionally referenced in the manifest.json
, but as buildImage
doesn’t (yet) produce such a file it would be also ok the delete the config of the parent.
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.
@lo1tuma Ok, the latest patch did this.
FYI, regarding the manifest.json and image config, I started to work a bit on them https://github.com/nlewo/nixpkgs-contrail/blob/master/jobset.nix#L40 since they are required to push the image to a v2 registry.
I will try to upstream these changes later.
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.
I also made a patch to make buildImage
produce image spec v1.2 compatible images, see holidaycheck@ece4233
Before submitting this patch to upstream I still want to implement a test for dockerTools
.
263890f
to
48c4c29
Compare
Verified this works with a similar testcase to the one in the issue:
|
Thanks |
Motivation for this change
Fix #27632
Things done
Please check what applies. Note that these are not hard requirements but mereley serve as information for reviewers.
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)