From fcc1283c855f67d5e2cc56a719a2b0b5ce63c9ee Mon Sep 17 00:00:00 2001 From: Steve Kamerman Date: Mon, 16 Oct 2017 23:31:26 -0400 Subject: [PATCH] Added install_clean.sh utility --- README.md | 1 + image/bin/install_clean.sh | 10 ++++++++++ image/utilities.sh | 3 +++ 3 files changed, 14 insertions(+) create mode 100755 image/bin/install_clean.sh diff --git a/README.md b/README.md index 6864072..b123b60 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ You can configure the stock `ubuntu` image yourself from your Dockerfile, so why | cron | The cron daemon must be running for cron jobs to work. | | [runit](http://smarden.org/runit/) | Replaces Ubuntu's Upstart. Used for service supervision and management. Much easier to use than SysV init and supports restarting daemons when they crash. Much easier to use and more lightweight than Upstart. | | `setuser` | A tool for running a command as another user. Easier to use than `su`, has a smaller attack vector than `sudo`, and unlike `chpst` this tool sets `$HOME` correctly. Available as `/sbin/setuser`. | +| `install_clean.sh` | A tool for installing `apt` packages that automatically cleans up after itself. All arguments are passed to `apt-get -y install` and after installation the apt caches are cleared. | Baseimage-docker is very lightweight: it only consumes 6 MB of memory. diff --git a/image/bin/install_clean.sh b/image/bin/install_clean.sh new file mode 100755 index 0000000..2a5310b --- /dev/null +++ b/image/bin/install_clean.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Apt installer helper for Docker images + +set -e + +echo "Installing $*" +apt-get -q update && apt-get -qy install $* \ + && apt-get -qy autoremove \ + && apt-get clean \ + && rm -r /var/lib/apt/lists/* diff --git a/image/utilities.sh b/image/utilities.sh index 9f0c1a9..8b452db 100755 --- a/image/utilities.sh +++ b/image/utilities.sh @@ -9,3 +9,6 @@ ln -s /usr/bin/vim.tiny /usr/bin/vim ## This tool runs a command as another user and sets $HOME. cp /bd_build/bin/setuser /sbin/setuser + +## This tool allows installation of apt packages with automatic cache cleanup. +cp /bd_build/bin/install_clean.sh /sbin/install_clean.sh