docker 실행 후, docker 프로세스의 memory 증가로 oom이 발생되고 os에서 docker 프로세스를 죽일 수 있다.


기본 docker 메모리는 unlimited이다.




$ cat /sys/fs/cgroup/memory/system.slice/docker.service/memory.stat 

cache 878325760

rss 58626048

rss_huge 0

mapped_file 20238336

dirty 0

writeback 0

swap 0

pgpgin 758173

pgpgout 529425

pgfault 431213

pgmajfault 1

inactive_anon 12288

active_anon 58683392

inactive_file 587464704

active_file 290791424

unevictable 0

hierarchical_memory_limit 9223372036854771712

hierarchical_memsw_limit 9223372036854771712

total_cache 878325760

total_rss 58626048

total_rss_huge 0

total_mapped_file 20238336

total_dirty 0

total_writeback 0

total_swap 0

total_pgpgin 758173

total_pgpgout 529425

total_pgfault 431213

total_pgmajfault 1

total_inactive_anon 12288

total_active_anon 58683392

total_inactive_file 587464704

total_active_file 290791424

total_unevictable 0






그런데. docker 메모리가 죽지 않도록 하려면. 다음과 같은 옵션을 docker run시 실행해야 한다. 


--oom-score-adj 값

--oom-kill-disable=true




관련된 도커 문서는 https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources에 존재한다.


문서에는 메모리 설정 내용이 포함되어 있다. 


Runtime constraints on resources

The operator can also adjust the performance parameters of the container:

OptionDescription
-m--memory=""Memory limit (format: <number>[<unit>]). Number is a positive integer. Unit can be one of bkm, or g. Minimum is 4M.
--memory-swap=""Total memory limit (memory + swap, format: <number>[<unit>]). Number is a positive integer. Unit can be one of bkm, or g.
--memory-reservation=""Memory soft limit (format: <number>[<unit>]). Number is a positive integer. Unit can be one of bkm, or g.
--kernel-memory=""Kernel memory limit (format: <number>[<unit>]). Number is a positive integer. Unit can be one of bkm, or g. Minimum is 4M.



잘 파신 분의 블로그

https://blog.2dal.com/2017/03/27/docker-and-oom-killer/


Posted by 김용환 '김용환'