# Check the container's last exit code
-weight: 500;">docker inspect <container_name> | grep -A 5 '"State"'
# Check the container's last exit code
-weight: 500;">docker inspect <container_name> | grep -A 5 '"State"'
# Check the container's last exit code
-weight: 500;">docker inspect <container_name> | grep -A 5 '"State"'
"OOMKilled": true
"State": { "Status": "exited", "Running": false, "OOMKilled": true, "ExitCode": 137
}
"State": { "Status": "exited", "Running": false, "OOMKilled": true, "ExitCode": 137
}
"State": { "Status": "exited", "Running": false, "OOMKilled": true, "ExitCode": 137
}
-weight: 600;">sudo dmesg | grep -i "oom\|killed process" | tail -20
-weight: 600;">sudo dmesg | grep -i "oom\|killed process" | tail -20
-weight: 600;">sudo dmesg | grep -i "oom\|killed process" | tail -20
Out of memory: Kill process 12345 (node) score 847 or sacrifice child
Killed process 12345 (node) total-vm:2048000kB, anon-rss:1834000kB
Out of memory: Kill process 12345 (node) score 847 or sacrifice child
Killed process 12345 (node) total-vm:2048000kB, anon-rss:1834000kB
Out of memory: Kill process 12345 (node) score 847 or sacrifice child
Killed process 12345 (node) total-vm:2048000kB, anon-rss:1834000kB
# Live container stats
-weight: 500;">docker stats --no-stream # Check if a memory limit is set
-weight: 500;">docker inspect <container_name> | grep -i memory
# Live container stats
-weight: 500;">docker stats --no-stream # Check if a memory limit is set
-weight: 500;">docker inspect <container_name> | grep -i memory
# Live container stats
-weight: 500;">docker stats --no-stream # Check if a memory limit is set
-weight: 500;">docker inspect <container_name> | grep -i memory
MemoryLimit
# Run with limit
-weight: 500;">docker run -m 512m your-image # Or -weight: 500;">update a running container
-weight: 500;">docker -weight: 500;">update --memory 512m --memory-swap 512m <container_name>
# Run with limit
-weight: 500;">docker run -m 512m your-image # Or -weight: 500;">update a running container
-weight: 500;">docker -weight: 500;">update --memory 512m --memory-swap 512m <container_name>
# Run with limit
-weight: 500;">docker run -m 512m your-image # Or -weight: 500;">update a running container
-weight: 500;">docker -weight: 500;">update --memory 512m --memory-swap 512m <container_name>
services: app: image: your-image deploy: resources: limits: memory: 512M
services: app: image: your-image deploy: resources: limits: memory: 512M
services: app: image: your-image deploy: resources: limits: memory: 512M
# Get a shell in the container
-weight: 500;">docker exec -it <container_name> sh # Check process memory inside container
top
# or
cat /proc/meminfo
# Get a shell in the container
-weight: 500;">docker exec -it <container_name> sh # Check process memory inside container
top
# or
cat /proc/meminfo
# Get a shell in the container
-weight: 500;">docker exec -it <container_name> sh # Check process memory inside container
top
# or
cat /proc/meminfo
# Check heap usage
node --max-old-space-size=256 server.js # Add memory monitoring
node -e "setInterval(() => console.log(process.memoryUsage()), 5000)" &
# Check heap usage
node --max-old-space-size=256 server.js # Add memory monitoring
node -e "setInterval(() => console.log(process.memoryUsage()), 5000)" &
# Check heap usage
node --max-old-space-size=256 server.js # Add memory monitoring
node -e "setInterval(() => console.log(process.memoryUsage()), 5000)" &
-weight: 500;">docker run ---weight: 500;">restart=unless-stopped -m 512m your-image
-weight: 500;">docker run ---weight: 500;">restart=unless-stopped -m 512m your-image
-weight: 500;">docker run ---weight: 500;">restart=unless-stopped -m 512m your-image
-weight: 500;">docker stats
watch -n 5 -weight: 500;">docker stats --no-stream - [ ] Always set --memory limits in production
- [ ] Set up alerting when container memory > 80%
- [ ] Add heap dump tooling to Node/Java apps
- [ ] Monitor with -weight: 500;">docker stats in a loop: watch -n 5 -weight: 500;">docker stats --no-stream