Lesson 2 of 9 · 28m
Capturing Ephemeral Evidence Before Cleanup Wins
Prioritize volatile container evidence, freeze state safely, export filesystems and logs, and avoid acquisition actions that trigger deletion or overwrite artifacts.
Ephemeral infrastructure does not mean evidence instantly vanishes. It means deletion is automated, routine, and unbothered by your investigation. Kubernetes reaps failed pods. Autoscalers terminate nodes. Runtime garbage collection prunes images. Log agents rotate files. Your first forensic decision is which evidence disappears first and which collection action makes things worse.
Work a volatility order
A practical order is:
1. memory, open descriptors, connections, running process state
2. stopped-container runtime state
3. stdout/stderr and node-local pod logs
4. writable layer, scratch space, bind mounts
5. image and layer cache
6. kubelet, runtime, journal, cloud audit logs
7. centralized logs, metrics, object archivesDo not memorize this as law. A stable overlay layer can outlive a short cloud-log retention window. Identify the actual decay mechanisms in front of you.
Freeze before you mutate
If policy permits, pause a live container before detailed inspection:
docker pause 4f7c9c...
crictl stop -t 0 9c31d...Pausing freezes scheduling but does not preserve memory. Stopping can trigger termination hooks and orchestrator replacement. On Kubernetes, cordon the node or disable scale-down while preserving pod state; a node autoscaler is an evidence destruction engine with excellent intentions.
Export, copy, hash
Docker can export a container filesystem without starting it:
mkdir -p evidence/container-4f7c9c
docker export 4f7c9c... -o evidence/container-4f7c9c/filesystem.tar
sha256sum evidence/container-4f7c9c/filesystem.tar > evidence/SHA256SUMS
docker diff 4f7c9c... | sort > evidence/container-4f7c9c/diff.txtdocker diff quickly separates container writes from the image. For containerd, snapshot paths and namespaces vary; inspect before copying. A typical overlay snapshot may sit under /var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/<id>/fs, but do not guess.
Capture logs and runtime context
Runtime logs rotate and are often JSON files. Preserve node-local logs before relying on the API:
sudo cp -a /var/log/pods evidence/var-log-pods-copy
kubectl -n prod logs deploy/payments --all-containers=true --previous=true > evidence/payments-previous.logkubectl logs is a supplement, not a complete acquisition. It can miss rotated files, terminated instances, init containers, and output already lost.
For still-running processes, preserve high-value context:
sudo cat /proc/$pid/cmdline | tr 'sudo cat /proc/$pid/cgroup > evidence/proc-$pid-cgroup.txt
sudo cat /proc/$pid/mountinfo > evidence/proc-$pid-mountinfo.txt
sudo ls -la /proc/$pid/fd > evidence/proc-$pid-fd.txtMemory acquisition is intrusive. If injected payloads, fileless malware, or credentials matter, decide explicitly whether the risk is justified. A filesystem export after memory loss is not a substitute.
Field notes
--previousonly works while the previous instance's logs survive.- Exports omit image metadata and runtime configuration; pair them with inspect output.
- Copying through a shell inside the container alters evidence. Prefer host-side collection.
- Autoscalers, cleanup controllers, and log rotation are often the first responders against you.
Was this lesson helpful?