[1] docker stats [docker guide]

Display a live stream of container(s) resource usage statistics

실시간으로 컨테이너들이 시스템에서 사용 중인 리소스를 보여준다.

  • CPU 사용량 | Memory 사용량 & Limit | I/O | PID
docker stats {컨테이너명} {컨테이너 ID} 

 

  • CPU 사용량 | Memory 사용량 & Limit
docker stats --all --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" {컨테이너명} {컨테이너명} {컨테이너명}

[2] Runtime options with Memory, CPUs, and GPUs [docker guide]

By default, a container has no resource constraints and can use as much of a given resource as the host’s kernel scheduler allows. Docker provides ways to control how much memory, or CPU a container can use, setting runtime configuration flags of the docker run command. This section provides details on when you should set such limits and the possible implications of setting them.

Many of these features require your kernel to support Linux capabilities. To check for support, you can use the docker info command. If a capability is disabled in your kernel, you may see a warning at the end of the output like the following:

WARNING: No swap limit support

Consult your operating system’s documentation for enabling them. Learn more.

기본적으로 컨테이너에는 리소스 제한이 없으며 호스트의 커널 스케줄러가 허용하는 한 지정된 리소스를 많이 사용할 수 있습니다. Docker는 docker run command 의 런타임 플래그를 통해 컨테이너가 사용할 수있는 메모리 또는 CPU 양을 제어하는 ​​방법을 제공합니다. 이 섹션에서는 이러한 제한을 설정해야하는 시기와 설정의 의미에 대해 설명합니다.

이러한 기능 중 다수는 Linux 기능을 지원하기 위해 커널이 필요합니다. 지원 여부를 확인하기 위해 docker info명령을 사용할 수 있습니다 . 커널에서 기능이 비활성화 된 경우 다음과 같이 출력 끝에 경고가 표시 될 수 있습니다.

메모리 액세스 제한 (커널 메모리 설명도 있지만 여기선 다루지 않았습니다.)

  • -m or --moemory= 

컨테이너가 사용할 수있는 최대 메모리 양. 이 옵션을 설정하면 허용되는 최소값은 4m(4MB)입니다.

  • --memory-swap*

이 컨테이너가 디스크로 스왑 할 수있는 메모리 양입니다. 자세한 --memory-swap내용을 참조 하십시오 .

  • --memory-reservation

--memoryDocker가 호스트 시스템에서 경합 또는 메모리 부족을 감지 할 때 활성화되는 것보다 작은 소프트 한계를 지정할 수 있습니다. --memory-reservation를 사용하는 경우, 우선 순위 --memory보다 낮게 설정해야합니다. 한계이므로 컨테이너가 한계를 초과하지는 않습니다.

CPU

기본 스케줄러 구성

  • 초당 최대 CPU 50% (docker 1.13 이상)
docker run -it --cpus=".5" ubuntu /bin/bash

-cpus="1.5"하면 컨테이너는 최대 1/5의 CPU를 보장합니다. 이것은 설정 --cpu-period="100000"과 동일합니다.

  • docker 1.12 이하
docker run -it --cpu-period=100000 --cpu-quota=50000 ubuntu /bin/bash

 

  • --cpu-period CPU CFS 스케줄러 기간

--cpu-quota. 기본값은 100 마이크로 초입니다. 대부분의 사용자는 이것을 기본값에서 변경하지 않습니다.

  • --cpu-quota CPU CFS 할당량

--cpu-period컨테이너  제한 시간 (마이크로 초) 은 제한 전에 제한됩니다.

반응형

+ Recent posts