-
Notifications
You must be signed in to change notification settings - Fork 954
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
Docker image size reduction #3319
base: main
Are you sure you want to change the base?
Conversation
ea412ab
to
5991aad
Compare
5991aad
to
d6901ff
Compare
d6901ff
to
013efed
Compare
02675f9
to
b886175
Compare
b886175
to
0271641
Compare
c02f5fd
to
e869067
Compare
0f7b630
to
087ba15
Compare
7f2cebb
to
69e8b98
Compare
images/Dockerfile
Outdated
# The second `apt-get update` isn't strictly necessary, but let's leave it here to force the | ||
# image build to break if the ppa is suddenly unavailable. | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends curl unzip sudo lsb-release gpg-agent software-properties-common \ |
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.
Could you maybe add the comment
# 'gpg-agent' and 'software-properties-common' are needed for the 'add-apt-repository' command that follows
here so it is clear, why you need this?
But why the others? Is sudo
and lsb-release
already needed at this stage?
images/Dockerfile
Outdated
# Install a sane set of base utilities and upgrade all system packages | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends sudo lsb-release gpg-agent software-properties-common curl git jq unzip \ | ||
&& apt-get upgrade -y \ |
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 is probably a question of style – but as far as I can see (and what I read from them), microsoft keeps the base image very up to date – so, maybe this is not really needed?
This reduces the overall runtime image size by >300MB. - Use heredoc shell steps. It's just more readable. - Move git-core/ppa installs to the build stage. - Move Docker CLI install to a simple COPY from the upstream docker.io/docker:cli image - Remove dockerd components. This image assumes that your dockerd is running outside of this container, probably as part of a k8s Pod.
69e8b98
to
1836384
Compare
@joh-klein Since the whole Dockerfile has been updated, I went all-in. I took into account your suggestions. Have a look. |
This reduces the overall on-disk image size by ~348MB (amd64) and the download size by ~146MB. For those of us who use runners in containers/k8s, the network traffic is reduced by a considerable 29%.