docker run --memory 메모리 제한하기

1 개요[ | ]

docker run --memory
docker run -m
docker run 메모리 제한하기
docker run --memory 50M ...
docker run -m 50M ...

2 실행예시[ | ]

50M 제한, 넘지 않은 경우(24M × 2)
root@localhost:~# docker run -m 50M --name stress --rm -it progrium/stress --timeout 10s --vm 2 --vm-bytes 24M
stress: info: [1] dispatching hogs: 0 cpu, 0 io, 2 vm, 0 hdd
stress: dbug: [1] using backoff sleep of 6000us
stress: dbug: [1] setting timeout to 10s
stress: dbug: [1] --> hogvm worker 2 [6] forked
stress: dbug: [1] using backoff sleep of 3000us
stress: dbug: [1] setting timeout to 10s
stress: dbug: [1] --> hogvm worker 1 [7] forked
stress: dbug: [7] allocating 25165824 bytes ...
stress: dbug: [7] touching bytes in strides of 4096 bytes ...
stress: dbug: [6] allocating 25165824 bytes ...
stress: dbug: [6] touching bytes in strides of 4096 bytes ...
stress: dbug: [7] freed 25165824 bytes
...
stress: dbug: [7] allocating 25165824 bytes ...
stress: dbug: [7] touching bytes in strides of 4096 bytes ...
stress: dbug: [7] freed 25165824 bytes
stress: dbug: [1] <-- worker 6 signalled normally
stress: dbug: [1] <-- worker 7 signalled normally
stress: info: [1] successful run completed in 10s
→ 2개의 프로세스(PID 6, 7)가 각각 24M의 메모리(총 48M)를 할당/해제하는 일을 반복하는데, 50M을 넘지 않으므로 10초간 정상실행되었다.
50M 제한, 넘은 경우(25M × 2)
root@localhost:~# docker run -m 50M --name stress --rm -it progrium/stress --timeout 10s --vm 2 --vm-bytes 25M
stress: info: [1] dispatching hogs: 0 cpu, 0 io, 2 vm, 0 hdd
stress: dbug: [1] using backoff sleep of 6000us
stress: dbug: [1] setting timeout to 10s
stress: dbug: [1] --> hogvm worker 2 [6] forked
stress: dbug: [1] using backoff sleep of 3000us
stress: dbug: [1] setting timeout to 10s
stress: dbug: [1] --> hogvm worker 1 [7] forked
stress: dbug: [7] allocating 26214400 bytes ...
stress: dbug: [7] touching bytes in strides of 4096 bytes ...
stress: dbug: [6] allocating 26214400 bytes ...
stress: dbug: [6] touching bytes in strides of 4096 bytes ...
stress: FAIL: [1] (416) <-- worker 6 got signal 9
stress: WARN: [1] (418) now reaping child worker processes
stress: dbug: [1] <-- worker 7 reaped
stress: FAIL: [1] (452) failed run completed in 0s
→ 2개의 프로세스(PID 6, 7)가 각각 25M의 메모리(총 50M)를 할당/해제하는 일을 반복하려고 하는데, 50M을 넘게 되자 6번 프로세스는 signal 9을 받고 강제종료되었고 컨테이너는 0초만에 failed로 종료되었다.

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}