-
Notifications
You must be signed in to change notification settings - Fork 659
Remove redundant apk update calls in Dockerfile #1123
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
base: main
Are you sure you want to change the base?
Conversation
Removed unnecessary `apk update` commands in Dockerfile. The apk add commands already utilize the `--no-cache` option, making the update step superfluous and ensuring the latest packages are used without maintaining a local cache. An additional `apk update` in another Docker image layer will increase the image size with no benefits.
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.
This PR looks good overall. It correctly adds explicit apk upgrade --no-cache
commands in both build stages of the Dockerfile. I have one minor suggestion to improve the documentation.
I'm not entirely sure, but Claude tells me that: The --no-cache flag does NOT fetch the latest package information. It only prevents apk from storing the package cache locally after installation. The --no-cache flag is purely about cache storage, not about refreshing the package index. apk upgrade --no-cache uses the existing package index to upgrade packages Correct behavior: apk update && apk upgrade --no-cache - Updates index, then upgrades to latest versions |
The usage from
Moreover, this can be confirmed through actual actions: # apk upgrade --no-cache
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/community/x86_64/APKINDEX.tar.gz
OK: 10 MiB in 18 packages |
I asked Claude Opus 4 (reasoning):
The answer is:
|
Answer from Gemini 2.5 Pro(https://gemini.google.com) using the same question:
|
Answer from o3(https://chatgpt.com/) using the same question:
|
Haha, thanks! Looks good to me then :) |
Description
Remove redundant
apk update
calls in Dockerfile. Theapk upgrade
commands already utilize the--no-cache
option, making the separate update step superfluous and ensuring the latest packages are used without maintaining a local cache.Motivation
An additional
apk update
in Docker image layers increases the image size with no benefits sinceapk upgrade --no-cache
already fetches the latest package information.Type of Change
How Has This Been Tested?
Checklist