Container Security für Docker & Kubernetes — 70% laufen als root. Hier ist der Fix.
70% aller Docker-Container laufen als root – ein kritisches Sicherheitsrisiko. Umfassende Container Security für Moltbot: von gehärteten Dockerfiles über Kubernetes Network Policies bis hin zu Runtime Protection mit Falco.
Warum ist Container Security kritisch? Einfach erklärt
Stell dir vor, du hättest dein Haus in einen Container gepackt — aber die Tür ist unverschlossen und du hast dem Mieter die Hausschlüssel gegeben. Docker-Container laufen standardmäßig als root-User, was bedeutet: Ein Angreifer, der aus dem Container ausbricht, hat sofort root-Zugriff auf den Host. Kubernetes-Cluster mit offenen Network Policies erlauben jedem Pod, mit jedem anderen zu sprechen — perfekt für laterale Bewegungen. Dieser Guide schließt alle diese Lücken systematisch.
🚨 Kritische Statistik: 70% aller Docker-Container laufen als root. 58% haben keine Security Contexts. 40% haben keine Resource Limits.
↓ Springe direkt zu gehärteten Dockerfiles und K8s-Konfigurationen unten
Gehärtetes Dockerfile (Production-Ready)
# Moltbot Production Dockerfile (gehärtet) FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci --only=production && npm cache clean --force COPY . . RUN npm run build FROM node:20-alpine AS runner # Security: Non-root user RUN addgroup -g 1001 -S moltbot && adduser -S moltbot -u 1001 -G moltbot WORKDIR /app # Security: Read-only filesystem COPY --chown=moltbot:moltbot --from=builder /app/.next/standalone ./ COPY --chown=moltbot:moltbot --from=builder /app/public ./public USER moltbot EXPOSE 3000 ENV NODE_ENV=production PORT=3000 # Security: No privileged operations CMD ["node", "server.js"]
Kubernetes Network Policy (Zero Trust)
# moltbot-network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: moltbot-netpol
namespace: production
spec:
podSelector:
matchLabels:
app: moltbot
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
role: ingress-controller
ports:
- protocol: TCP
port: 3000
egress:
- to:
- podSelector:
matchLabels:
app: postgres
ports:
- protocol: TCP
port: 5432
- to:
- namespaceSelector:
matchLabels:
name: kube-system
ports:
- protocol: UDP
port: 53 # DNSPod Security Standards & Security Context
# moltbot-deployment.yaml (security context)
apiVersion: apps/v1
kind: Deployment
metadata:
name: moltbot
spec:
template:
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1001
fsGroup: 1001
seccompProfile:
type: RuntimeDefault
containers:
- name: moltbot
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
resources:
limits:
cpu: "500m"
memory: "512Mi"
requests:
cpu: "100m"
memory: "128Mi"