Hardened Apache Spark 4.1.2: PySpark, Java 21, Scala 2.13, Python 3, Debian 13, multi-arch, non-root
1.3K
Minimal, security-hardened Apache Spark 4.1 (PySpark) on Debian 13 (trixie).
Two-stage build (download + GPG/SHA512 verify โ clean runtime), runs as a
non-root user, multi-arch (amd64/arm64), built to follow the
Docker Hardened Imagesโ
Spark conventions (Debian 13 base, non-root uid 65532, /opt/spark layout,
JRE under /opt/java/openjdk).
setpriv (util-linux, C) โ no gosu, so no Go runtime / Go-stdlib CVE surface.patch-jars.sh upgrades the cleanly-swappable bundled libraries to fixed releases (Netty 4.2.15, Jackson 2.21.4, Derby 10.17, ZooKeeper 3.9.5), each verified against Maven Central's .sha1. The optional Spark Connect REPL bundle (which shaded a vulnerable Netty) is removed.openjdk-21-jre-headless (apt-patched, no AWT/GUI surface).python3 + pip); PYSPARK_PYTHON=python3 preset.gnupg/wget never reach it).linux/amd64, linux/arm64.driver / executor / pass-through modes) and the decommission helper at /opt/decom.sh.latest โ newest build.4.1.2-python3-java21 โ Spark 4.1.2, Scala 2.13, Java 21, Python 3, Debian 13.Note: Java 21 requires the Spark 4.x line. (Spark 3.5.x officially supports Java 8/11/17 only.) Spark 4.x ships Scala 2.13 exclusively.
| Base | debian:trixie-slim (Debian 13), digest-pinned |
| Spark | 4.1.2 (spark-4.1.2-bin-hadoop3) |
| Java | OpenJDK 21 (openjdk-21-jre-headless) |
| Scala | 2.13 |
| Python | 3 (Debian python3) |
| User | spark (uid/gid 65532), non-root |
SPARK_HOME | /opt/spark |
JAVA_HOME | /opt/java/openjdk/21-jre |
| Entrypoint | /opt/spark/bin/docker-entrypoint.sh |
| Workdir | /opt/spark/work-dir |
docker run --rm -it truebyteinnovationllp/spark:4.1.2-python3-java21 \
/opt/spark/bin/pyspark
docker run --rm truebyteinnovationllp/spark:4.1.2-python3-java21 \
/opt/spark/bin/spark-submit \
--master 'local[*]' \
--class org.apache.spark.examples.SparkPi \
/opt/spark/examples/jars/spark-examples.jar 100
docker run --rm -v "$PWD":/work \
truebyteinnovationllp/spark:4.1.2-python3-java21 \
/opt/spark/bin/spark-submit --master 'local[*]' /work/job.py
The entrypoint understands the driver and executor commands used by
spark-submit --master k8s://โฆ. Point spark.kubernetes.container.image at
this image; it runs unprivileged by default and switches to the spark user
via gosu if a pod starts as root.
--read-only (mount a writable volume at
/opt/spark/work-dir if your job writes there).--cap-drop=ALL; the image needs none.wget/gnupg2 exist only in the builder stage.cosign verify --key cosign.pub truebyteinnovationllp/spark:4.1.2-python3-java21
Unlike the from-source images in this repo, Spark ships a large, fixed set of prebuilt upstream JARs, so literal "zero CVE" is not achievable by patching a tarball โ the upstream Docker Hardened Image reaches zero only by rebuilding Spark from source against patched dependencies. This image instead does the honest, maintainable thing:
patch-jars.sh: Netty 4.2.15, Jackson 2.21.4, Derby 10.17, ZooKeeper 3.9.5).gosu/Go)..trivyignoreโ and
spark.openvex.jsonโ , each with a written justification.The CI gate is Trivy honouring .trivyignore, so the build still fails on any
new, undocumented HIGH/CRITICAL โ only the reviewed residuals pass.
| HIGH/CRITICAL | |
|---|---|
| Stock Spark 4.1.2 tarball | ~58 |
| This image (raw) | ~34 โ all triaged |
| This image (undocumented) | 0 โ |
The residual ~34 are: Jackson shaded inside Hadoop/Parquet uber-jars (Spark's
own classpath Jackson is patched); JLine telnet / Jetty UI / Thrift paths not
reachable in normal operation; lz4-java (no published fix); and Debian
userland packages marked fix_deferred (perl/expat/ncurses/python) that
apt upgrade will patch automatically once Debian ships them. Re-review on every
Spark/Debian bump and delete entries as they clear.
docker build -t spark:4.1.2-python3-java21 spark-docker/
# Override the version (also update SHA512 + GPG key together):
docker build \
--build-arg SPARK_VERSION=4.1.2 \
--build-arg SPARK_SHA512=<sha512> \
--build-arg GPG_KEY=<release-manager-fingerprint> \
-t spark:4.1.2-python3-java21 spark-docker/
Upstream sources: https://spark.apache.orgโ ยท signing keys: https://downloads.apache.org/spark/KEYSโ
Content type
Image
Digest
sha256:bc7e2e00cโฆ
Size
490.4 MB
Last updated
3 months ago
docker pull truebyteinnovationllp/spark