-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathdocker_run.sh
More file actions
executable file
·30 lines (24 loc) · 992 Bytes
/
docker_run.sh
File metadata and controls
executable file
·30 lines (24 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
set -euo pipefail
# Ensure host can execute arm64 binaries (idempotent). Faster to skip if already present.
if [[ ! -e /proc/sys/fs/binfmt_misc/qemu-aarch64 ]]; then
echo "[binfmt] installing qemu handlers on host."
docker run --rm --privileged tonistiigi/binfmt --install all
fi
# Make sure a buildx builder exists and is ready.
docker buildx create --use --name multi >/dev/null 2>&1 || docker buildx use multi
docker buildx inspect --bootstrap >/dev/null 2>&1 || true
IMAGE_TAG="kali-re-tools:arm64"
DOCKERFILE_SHA="$(sha256sum Dockerfile | awk '{print $1}')"
HASH_TAG="${IMAGE_TAG}-${DOCKERFILE_SHA}"
# build only when hash-tagged image is missing
if ! docker image inspect "$HASH_TAG" >/dev/null 2>&1; then
echo "[build] building $HASH_TAG"
docker buildx build --platform linux/arm64 -t "$HASH_TAG" --load .
else
echo "[build] up to date ($HASH_TAG)"
fi
# stable alias for compose
docker tag "$HASH_TAG" "$IMAGE_TAG"
# run
docker compose run --rm kali