You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just wanted to point out that deleting temporary files in a Dockerfile doesn't reduce image size — unless you delete them in the same RUN that created them.
This is because each RUN command builds a separate image layer. After a layer has been built, any files that it added to the image are "baked in" and will contribute to final image size even if you delete them in a subsequent layer. In such a case, the deletion only serves to make files inaccessible in the running container.
The solution is to execute downloads/installs and cleanups in the same RUN, so only the net result gets baked into the image. Files that were added then removed in the same RUN are completely excluded from the single resulting layer.
Just wanted to point out that deleting temporary files in a Dockerfile doesn't reduce image size — unless you delete them in the same RUN that created them.
This is because each RUN command builds a separate image layer. After a layer has been built, any files that it added to the image are "baked in" and will contribute to final image size even if you delete them in a subsequent layer. In such a case, the deletion only serves to make files inaccessible in the running container.
The solution is to execute downloads/installs and cleanups in the same RUN, so only the net result gets baked into the image. Files that were added then removed in the same RUN are completely excluded from the single resulting layer.
The text was updated successfully, but these errors were encountered: