From 408e6142cb3a0a2e85d60b01854d526201a6a007 Mon Sep 17 00:00:00 2001 From: David Schmitt <118179693+DavidS-ovm@users.noreply.github.com> Date: Mon, 17 Mar 2025 11:41:26 +0100 Subject: [PATCH] Add `apt clean` to reduce layer size The downloaded packages do not need to be kept in the layer. Running `apt clean` will remove them from the cache. To quote from apt's man page: > clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. --- src/docker-in-docker/install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh index 906393997..a2faa44fa 100755 --- a/src/docker-in-docker/install.sh +++ b/src/docker-in-docker/install.sh @@ -27,6 +27,7 @@ set -e # Clean up rm -rf /var/lib/apt/lists/* +apt clean # Setup STDERR. err() { @@ -427,6 +428,7 @@ if [ -f "/usr/local/share/docker-init.sh" ]; then echo "/usr/local/share/docker-init.sh already exists, so exiting." # Clean up rm -rf /var/lib/apt/lists/* + apt clean exit 0 fi echo "docker-init doesn't exist, adding..." @@ -640,5 +642,6 @@ chown ${USERNAME}:root /usr/local/share/docker-init.sh # Clean up rm -rf /var/lib/apt/lists/* +apt clean echo 'docker-in-docker-debian script has completed!'