Container image for python-k8s-runner
7.7K
Minimal distroless Python runtime for scripts that are mounted into the container from outside, e.g. via ConfigMap in Kubernetes.
nonroot, UID 65532)The image does not contain a script. python is the entrypoint, the script to run is passed as argument.
docker run --rm --read-only \
-v $(pwd)/scripts:/app:ro \
ghcr.io/tuxpeople/python-k8s-runner:latest \
script.py
apiVersion: v1
kind: Pod
metadata:
name: python-k8s-runner
spec:
containers:
- name: runner
image: ghcr.io/tuxpeople/python-k8s-runner:latest
args: ["/app/script.py"]
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
volumeMounts:
- name: script
mountPath: /app
readOnly: true
# Only needed if the script writes temporary files
# - name: tmp
# mountPath: /tmp
volumes:
- name: script
configMap:
name: my-script
# - name: tmp
# emptyDir: {}
See requirements.txt.
| Variable | Value | Purpose |
|---|---|---|
PYTHONUNBUFFERED | 1 | Output shows up in kubectl logs immediately |
PYTHONDONTWRITEBYTECODE | 1 | No .pyc files next to read-only mounted scripts |
This image has no Goss tests and no CMD ["sleep", "infinity"]. This is a technical limitation: the distroless runtime has no shell and no sleep binary, and dgoss needs a shell inside the container to run goss. The image is validated by Hadolint, the multi-arch build and the Trivy scan.
Check locally that a script runs:
docker build -t python-k8s-runner:test ./images/python-k8s-runner
docker run --rm --read-only -v $(pwd)/scripts:/app:ro python-k8s-runner:test script.py
latest - Latest stable releaseX.Y.Z - Specific versionX.Y - Minor version (floating)X - Major version (floating)main - Latest build from main branchnightly - Nightly buildnonroot (UID 65532)Content type
Image
Digest
sha256:03361d020…
Size
28 MB
Last updated
5 minutes ago
docker pull tdeutsch/python-k8s-runner