Prevent removing unexpected .a files in case of re-using the Dockerfile to build custom image #706
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, I'd like to propose a slight change for cleaning up
*.a
which is defined here, so that it doesn't delete unexpected files.python/3.10/slim-buster/Dockerfile
Line 92 in 0047f00
Here is my background:
The current Dockerfile for the dockerhub Python image itself works pretty fine; it doesn't remove anything unexpected, even without my proposal.
However, since this official Dockerfile is so useful, clean and general, we often re-use (borrow) its content to make our own images on top of another image, typically by just rewriting the
FROM
section to something other.For example, which is my actual case, we build a Python-ready image on top of
nvidia/cuda:11.6.0-xxx
. The issue here is that removing all the*.a
under/usr/local
as written in the current Dockerfile also destroys CUDA libraries. This combination is just an example but I think the same thing can happen in other patterns.Looking at the actual files cleaned up here while building Python 3.10 images for
slim-buster
andalpine3.15
, I found out/usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.a
is the only*.a
file removed. So I think modifying the rule for thefind
command from'*.a'
to'libpython*.a'
can prevent unexpectedly removing .a files of other libraries in case modifyingFROM
section, while it doesn't change anything on the image for dockerhub.