mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-18 17:14:39 -04:00
bring image back down to 700mb
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Build Debian package / build (push) Waiting to run
Build Docker image / buildx (push) Waiting to run
Deploy static content to Pages / deploy (push) Waiting to run
Build Homebrew package / build (push) Waiting to run
Build GitHub Pages website / build (push) Waiting to run
Build GitHub Pages website / deploy (push) Blocked by required conditions
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Run tests / python_tests (ubuntu-22.04, 3.11) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Build Debian package / build (push) Waiting to run
Build Docker image / buildx (push) Waiting to run
Deploy static content to Pages / deploy (push) Waiting to run
Build Homebrew package / build (push) Waiting to run
Build GitHub Pages website / build (push) Waiting to run
Build GitHub Pages website / deploy (push) Blocked by required conditions
Run linters / lint (push) Waiting to run
Build Pip package / build (push) Waiting to run
Run tests / python_tests (ubuntu-22.04, 3.11) (push) Waiting to run
Run tests / docker_tests (push) Waiting to run
This commit is contained in:
parent
47a7cabc68
commit
54d4d7f640
3 changed files with 102 additions and 52 deletions
47
bin/docker_layers.sh
Executable file
47
bin/docker_layers.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script takes a single Docker image tag (e.g. "ubuntu:latest") as input
|
||||
# and shows the contents of the filesystem for each layer in the image.
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Usage: $0 <image_tag>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE=$1
|
||||
# TMPDIR=$(mktemp -d)
|
||||
mkdir -p "$PWD/tmp"
|
||||
TMPDIR="$PWD/tmp"
|
||||
|
||||
# Save the Docker image to a tar archive
|
||||
echo "Saving Docker image '$IMAGE'..."
|
||||
if ! docker save "$IMAGE" | pv > "${TMPDIR}/image.tar"; then
|
||||
echo "Failed to save image '$IMAGE'. Make sure the image exists and Docker is running."
|
||||
rm -rf "${TMPDIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${TMPDIR}" || exit 1
|
||||
|
||||
# Extract the top-level metadata of the image tar
|
||||
echo "Extracting image metadata..."
|
||||
pwd
|
||||
tar -xzf image.tar
|
||||
chmod -R 777 .
|
||||
cd blobs/sha256 || exit 1
|
||||
|
||||
# Typically, the saved image will contain multiple directories each representing a layer.
|
||||
# Each layer directory should have a 'layer.tar' file that contains the filesystem for that layer.
|
||||
for LAYERFILE in ./*; do
|
||||
if [ -f "${LAYERFILE}" ]; then
|
||||
mv "${LAYERFILE}" "${LAYERFILE}.tar"
|
||||
tar -xzf "${LAYERFILE}.tar"
|
||||
rm "${LAYERFILE}.tar"
|
||||
echo "-----------------------------------------------------------------"
|
||||
echo "Contents of layer: ${LAYERFILE%/}"
|
||||
echo "-----------------------------------------------------------------"
|
||||
# List the files in the layer.tar without extracting
|
||||
tree -L 2
|
||||
echo
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue