Interview Prep/Docker/Resources, health checks, logging and restarts

Java container ignores memory limit and uses host memory (old JDK): `OutOfMemoryError` or killed.

AdvancedTroubleshootingResources, health checks, logging and restarts
Answer

Likely causes → Older JDK (<8u191) doesn't read cgroup limits, so default heap is 25% of host RAM.

Diagnose → docker exec c java -XX:+PrintFlagsFinal -version | grep -E 'MaxHeapSize|UseContainerSupport'.

Fix → Upgrade JDK (11+/17/21), set -XX:MaxRAMPercentage=70, or explicit -Xmx.

Prevent → Use current LTS base images.

All Docker questions Roadmap: Docker & containers

More on Resources, health checks, logging and restarts