-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Revisiting mkimage-arch.sh #9764
Conversation
(I'm not an Arch Linux user, just stumbled on this PR) Don't know if |
@thaJeztah Thanks for the gist! It's a good base for comparison. What can you do with Also, So far the packages I stripped out fall into three categories. Packages that
What to include in a container is highly personal, so I tried to avoid imposing my personal preferences on the base image generation. For example I never used Obviously there is a fine line between what to strip out and what to include, and it is largely based on personal preference. What I want to achieve here, is to strip out packages that are widely believed to be unnecessary because they provide functionality that belongs to the host, highly application specific and/or not widely used. |
In my personal opinion, a base image should be a 'clean slate'; Editors are really personal and in most cases not even necessary (most containers won't be interactive). If someone wants to have an editor inside the container, he/she should create a base image, containing those tools. Tools like But, agreed, I think some other people should have a look as well. As said, I personally don't use this feature, so I'm not the best person to ask for a use case. |
I personally think the images should be clean as well and not include editors etc, but @tianon is the main deciding factor here |
I'm definitely +1 on removing editors, etc. from base images, but sometimes upstream isn't as privy to that (see Ubuntu as an example). |
awesome info - bookmarking for docs :) |
Thanks guys! I updated the pull request to remove @tianon let me know if you want me to squash the commits into one before merging. |
pcmciautils,usbutils,jfsutils,xfsprogs,reiserfsprogs,lvm2,mdadm,cryptsetup,\ | ||
device-mapper,man-db,man-pages,s-nail,nano,vi | ||
EOF | ||
) |
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.
Wouldn't this be easier to maintain long-term if we used something more like:
PKGIGNORE=(
cryptsetup
device-mapper
dhcpcd
iproute2
jfsutils
linux
lvm2
man-db
man-pages
mdadm
nano
netctl
openresolv
pciutils
pcmciautils
reiserfsprogs
s-nail
systemd-sysvcompat
usbutils
vi
xfsprogs
)
IFS=','
PKGIGNORE="${PKGIGNORE[*]}"
unset IFS
With the list of @tianon, those packages are being installed into the image: bzip2
coreutils
diffutils
e2fsprogs
file
filesystem
findutils
gawk
gcc-libs
gettext
glibc
grep
gzip
inetutils
iputils
less
licenses
logrotate
pacman
perl
procps-ng
psmisc
sed
shadow
sysfsutils
tar
texinfo
util-linux
which If we ignore the fact, that dockerfiles may depend on them, or they may be useful for most of the users, these packages could also be removed:
When leaving |
Docker-DCO-1.1-Signed-off-by: Zoltan Tombol <zoltan.tombol@gmail.com> (github: ztombol)
Docker-DCO-1.1-Signed-off-by: Zoltan Tombol <zoltan.tombol@gmail.com> (github: ztombol)
71fa3a3
to
18c0b41
Compare
@tianon good point. Amended. |
@dasJ so, in both Debian and Gentoo, there's an understanding in package metadata that packages in the base set are not required to be listed explicitly in dependencies of other packages -- is that true in Arch as well? ie, are packages allowed to assume that basic tools like |
This PR as-is LGTM anyhow, but I think there's clearly room for further discussion about the exist list of packages to purge. 👍 |
@dasJ You left out
I think this is the perfect argument against removing those packages.
I'm not sure about PS.: The list of installed packages in the OP was not correct. I missed |
LGTM |
@tianon That is not true for Arch. Packages list all run-time dependencies even if they are in So removing packages suggested by @dasJ may not prevent anyone from installing and using packaged applications. But user written scripts, e.g. docker entrypoint and related, would most likely fail. Note: There is a similar rule for packages built from source. They should not list compile time dependencies that are already in the |
Ah cool, thanks for clarifying! |
Overview
This pull request aims to clean up and slightly reduce the size of Arch Linux base images generated with
mkimage-arch.sh
. So far it does the following two things:These changes reduce the image size by 17.7 MB or ~5% (from 310.4 MB to 292.7 MB).
_Note:_ Image size is the VIRTUAL SIZE as reported by
docker inspect
on a btrfs file system. The test images were built around 2015-01-08 18:45:48 UTC.Details
Deleting man pages
The script already skips installing
man-db
andman-pages
to save on disk space, however it fails to delete man pages that belong to the installed packages.rm -r /usr/share/man/*
accomplishes just that, and reduces the image size by about 11.9 MB.Revising list of installed packages
This is more for cleaning up than to save a few megabytes, but it also further reduces the image size by 5.8 MB.
The following is a revised list of packages that should not be installed and a short explanation on why they should be left out, along with a few notes on packages that cannot be left out. Packages denoted with an * are already ignored in the current version of
mkimage-arch.sh
, the rest are new additions.linux*
,systemd-sysvcompat
- Containers do not boot.openresolv
-resolv.conf
is managed by the docker daemon.netctl
,dhcpcd
,iproute2
- Network interface is managed by the docker daemon.pciutils*
,pcmciautils*
,usbutils
- Hardware management is done by the host.jfsutils*
,xfsprogs*
,reiserfsprogs*
- File systems are managed by the host.lvm2*
,mdadm*
,cryptsetup*
,device-mapper
- Storage devices are managed by the host.man-db*
,man-pages*
- Documentation not useful inside a container.s-nail*
,nano
,vi
- Unlikely to be widely used.For completeness, here are the members of the
base
group that are installed.bash
,bzip2
,coreutils
,diffutils
,e2fsprogs
,file
,filesystem
,findutils
,gawk
,gcc-libs
,gettext
,glibc
,grep
,gzip
,inetutils
,iputils
,less
,licenses
,logrotate
,pacman
,perl
,procps-ng
,psmisc
,sed
,shadow
,sysfsutils
,tar
,texinfo
,util-linux
,which
._Note:_
groff
has been removed from the ignore list because it is actually not installed bybase
(it's inbase-devel
).Images sizes
The following table summarises the space saving introduced in this pull request. Images are cumulative in that an image also contains the changes made by the one above it, e.g. minimal packages also deletes the man pages. Differences in size are calculated against the image immediately above.
Feedback wanted
The patched script builds a working image, however it's possible that I overlooked an unnecessary package or removed an important one. I linked all package names to the respective pages on the Arch Linux web site to make it easier to review the changes. Let me know what you think.