docker/docker — pull request #9764 by ztombol (2014-12-21 03:22:08+00:00)
Title: Fix reduce arch rootfs size

# 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:

- prevent installing more unnecessary packages
- delete man pages of installed packages

These changes reduce the image size by 16.1 MB or ~5% (from 309.7 MB to 293.6 MB).

***Note:*** *Image size is the VIRTUAL SIZE as reported by `docker inspect` on a btrfs file system. The test images were built around 2014-12-21 00:49:28 UTC.*

# Details

## Deleting man pages

The script already skips installing [`man-db`][pkg-man-db] and [`man-pages`][pkg-man-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 4.2 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*`][pkg-linux], [`systemd-sysvcompat`][pkg-systemd-sysvcompat] - Containers do not boot.

> [`systemd`][pkg-systemd] - [`procps-ng`][pkg-procps-ng] (`pkill`, `pgrep`, etc.) depends on it.
- [`openresolv`][pkg-openresolv] - `resolv.conf` is managed by the docker daemon.
- [`netctl`][pkg-netctl],[`dhcpcd`][pkg-dhcpcd],[`iproute2`][pkg-iproute2] - Network interface is managed by the docker daemon.

> [`inetutils`][pkg-inetutils] - Contains `telnet` and `ftp`.
> [`iputils`][pkg-iputils] - Contains `ping`.
- [`pciutils*`][pkg-pciutils], [`pcmciautils*`][pkg-pcmciautils], [`usbutils`][pkg-usbutils] - Hardware management is done by the host.
- [`jfsutils*`][pkg-jfsutils], [`xfsprogs*`][pkg-xfsprogs], [`reiserfsprogs*`][pkg-reiserfsprogs] - File systems are managed by the host.

> [`e2fsprogs`][pkg-e2fspriogs] - [`pam`][pkg-pam], a `base` package indirectly depends on it.
- [`lvm2*`][pkg-lvm2], [`mdadm`][pkg-mdadm*], [`cryptsetup*`][pkg-cryptsetup], [`device-mapper`][pkg-device-mapper] - Storage devices are managed by the host.
- [`man-db*`][pkg-man-db], [`man-pages*`][pkg-man-pages] - Documentation not useful inside a container.

> [`texinfo`][pkg-texinfo] - `pacman` indirectly depends on it.
> [`licenses`][pkg-licenses] - Should not be left out, see [here][https://wiki.archlinux.org/index.php/PKGBUILD#license]
- [`s-nail*`][pkg-s-nail] - Unlikely to be widely used.

For completeness, here are the members of the `base` group that are installed.
[`bash`][pkg-bash], [`bzip2`][pkg-bzip2], [`coreutils`][pkg-coreutils], [`diffutils`][pkg-diffutils], [`file`][pkg-file], [`filesystem`][pkg-filesystem], [`findutils`][pkg-findutils], [`gawk`][pkg-gawk], [`gcc-libs`][pkg-gcc-libs], [`gettext`][pkg-gettext], [`glibc`][pkg-glibc], [`grep`][pkg-grep], [`gzip`][pkg-gzip], [`inetutils`][pkg-inetutils], [`iproute2`][pkg-iproute2], [`iputils`][pkg-iputils], [`less`][pkg-less], [`licenses`][pkg-licenses], [`logrotate`][pkg-logrotate], [`nano`][pkg-nano], [`pacman`][pkg-pacman], [`perl`][pkg-perl], [`procps-ng`][pkg-procps-ng], [`psmisc`][pkg-psmisc], [`sed`][pkg-sed], [`shadow`][pkg-shadow], [`sysfsutils`][pkg-sysfsutils], [`tar`][pkg-tar], [`util-linux`][pkg-util-linux], [`vi`][pkg-vi], [`which`][pkg-which].

***Note:*** *`groff` has been removed from the ignore list because it is actually not installed by `base` (it's in `base-devel`).*

# 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.

[pkg-linux]: https://www.archlinux.org/packages/core/x86_64/linux/
[pkg-systemd-sysvcompat]: https://www.archlinux.org/packages/core/x86_64/systemd-sysvcompat/
[pkg-systemd]: https://www.archlinux.org/packages/core/x86_64/systemd/
[pkg-procps-ng]: https://www.archlinux.org/packages/core/x86_64/procps-ng/
[pkg-openresolv]: https://www.archlinux.org/packages/core/x86_64/openresolv/
[pkg-netctl]: https://www.archlinux.org/packages/core/x86_64/netctl/
[pkg-dhcpcd]: https://www.archlinux.org/packages/core/x86_64/dhcpcd/
[pkg-iproute2]: https://www.archlinux.org/packages/core/x86_64/iproute2/
[pkg-inetutils]: https://www.archlinux.org/packages/core/x86_64/inetutils/
[pkg-iputils]: https://www.archlinux.org/packages/core/x86_64/iputils/
[pkg-pciutils]: https://www.archlinux.org/packages/core/x86_64/pciutils/
[pkg-pcmciautils]: https://www.archlinux.org/packages/core/x86_64/pcmciautils/
[pkg-usbutils]: https://www.archlinux.org/packages/core/x86_64/usbutils/
[pkg-jfsutils]: https://www.archlinux.org/packages/core/x86_64/jfsutils/
[pkg-xfsprogs]: https://www.archlinux.org/packages/core/x86_64/xfsprogs/
[pkg-reiserfsprogs]: https://www.archlinux.org/packages/core/x86_64/reiserfsprogs/
[pkg-e2fspriogs]: https://www.archlinux.org/packages/core/x86_64/e2fspriogs/
[pkg-pam]: https://www.archlinux.org/packages/core/x86_64/pam/
[pkg-lvm2]: https://www.archlinux.org/packages/core/x86_64/lvm2/
[pkg-mdadm]: https://www.archlinux.org/packages/core/x86_64/mdadm/
[pkg-cryptsetup]: https://www.archlinux.org/packages/core/x86_64/cryptsetup/
[pkg-device-mapper]: https://www.archlinux.org/packages/core/x86_64/device-mapper/
[pkg-man-db]: https://www.archlinux.org/packages/core/x86_64/man-db/
[pkg-man-pages]: https://www.archlinux.org/packages/core/x86_64/man-pages/
[pkg-texinfo]: https://www.archlinux.org/packages/core/x86_64/texinfo/
[pkg-ca-certificates]: https://www.archlinux.org/packages/core/x86_64/ca-certificates/
[pkg-curl]: https://www.archlinux.org/packages/core/x86_64/curl/
[pkg-pacman]: https://www.archlinux.org/packages/core/x86_64/pacman/
[pkg-gnutls]: https://www.archlinux.org/packages/core/x86_64/gnutls/
[pkg-licenses]: https://www.archlinux.org/packages/core/x86_64/licenses/
[pkg-s-nail]: https://www.archlinux.org/packages/core/x86_64/s-nail/

[pkg-bash]: https://www.archlinux.org/packages/core/x86_64/bash/
[pkg-bzip2]: https://www.archlinux.org/packages/core/x86_64/bzip2/
[pkg-coreutils]: https://www.archlinux.org/packages/core/x86_64/coreutils/
[pkg-diffutils]: https://www.archlinux.org/packages/core/x86_64/diffutils/
[pkg-file]: https://www.archlinux.org/packages/core/x86_64/file/
[pkg-filesystem]: https://www.archlinux.org/packages/core/x86_64/filesystem/
[pkg-findutils]: https://www.archlinux.org/packages/core/x86_64/findutils/
[pkg-gawk]: https://www.archlinux.org/packages/core/x86_64/gawk/
[pkg-gcc-libs]: https://www.archlinux.org/packages/core/x86_64/gcc-libs/
[pkg-gettext]: https://www.archlinux.org/packages/core/x86_64/gettext/
[pkg-glibc]: https://www.archlinux.org/packages/core/x86_64/glibc/
[pkg-grep]: https://www.archlinux.org/packages/core/x86_64/grep/
[pkg-gzip]: https://www.archlinux.org/packages/core/x86_64/gzip/
[pkg-inetutils]: https://www.archlinux.org/packages/core/x86_64/inetutils/
[pkg-iproute2]: https://www.archlinux.org/packages/core/x86_64/iproute2/
[pkg-iputils]: https://www.archlinux.org/packages/core/x86_64/iputils/
[pkg-less]: https://www.archlinux.org/packages/core/x86_64/less/
[pkg-licenses]: https://www.archlinux.org/packages/core/x86_64/licenses/
[pkg-logrotate]: https://www.archlinux.org/packages/core/x86_64/logrotate/
[pkg-nano]: https://www.archlinux.org/packages/core/x86_64/nano/
[pkg-pacman]: https://www.archlinux.org/packages/core/x86_64/pacman/
[pkg-perl]: https://www.archlinux.org/packages/core/x86_64/perl/
[pkg-procps-ng]: https://www.archlinux.org/packages/core/x86_64/procps-ng/
[pkg-psmisc]: https://www.archlinux.org/packages/core/x86_64/psmisc/
[pkg-sed]: https://www.archlinux.org/packages/core/x86_64/sed/
[pkg-shadow]: https://www.archlinux.org/packages/core/x86_64/shadow/
[pkg-sysfsutils]: https://www.archlinux.org/packages/core/x86_64/sysfsutils/
[pkg-tar]: https://www.archlinux.org/packages/core/x86_64/tar/
[pkg-util-linux]: https://www.archlinux.org/packages/core/x86_64/util-linux/
[pkg-vi]: https://www.archlinux.org/packages/core/x86_64/vi/
[pkg-which]: https://www.archlinux.org/packages/core/x86_64/which/