how to check a container run out of memory in container
I found that journalctl can limit start_time and end_time so that below command can work well:
journalctl -k \ --since "`date -r file "+%Y-%m-%d %H:%M:%S"`" \ --until "`date "+%Y-%m-%d %H:%M:%S"`" | grep -q -F \ -e 'Out of memory' \ -e 'invoked oom-killer: gfp_mask=0x' \ -e ': page allocation failure: order:'
I take the file mtime as start time so that i can get all kernel info during test.
You can use :
docker container inspect your-container-name | jq .[].State.OOMKilled
Returns true/false.
docker container inspect return json formated stuff about the container. jq is like 'sed for json' and with '.[].State.OOMKilled' you filter informations about your container to find is it was OOMKilled or not.
Update :
You can use -f to archive the same thing :
docker container inspect your-container-name -f '{{json .State.OOMKilled}}'