Docker 2024 04/Resource Restriction: Unterschied zwischen den Versionen

Aus CCWiki
Zur Navigation springen Zur Suche springen
Zeile 36: Zeile 36:
1 Kern
1 Kern
{{BML|code=
{{BML|code=
docker run --cpu 1 --rm -it dockerschulung/resource_limiting_base:1.0 bash
docker run --cpus 1 --rm -it dockerschulung/resource_limiting_base:1.0 bash
# stress-ng cpu test (16 cores) for 10 seconds
# stress-ng cpu test (16 cores) for 10 seconds
stress-ng --cpu 16 --timeout 10s
stress-ng --cpu 16 --timeout 10s
Zeile 43: Zeile 43:
2 Kerne
2 Kerne
{{BML|code=
{{BML|code=
docker run --cpu 2 --rm -it dockerschulung/resource_limiting_base:1.0 bash
docker run --cpus 2 --rm -it dockerschulung/resource_limiting_base:1.0 bash
# stress-ng cpu test (16 cores) for 10 seconds
# stress-ng cpu test (16 cores) for 10 seconds
stress-ng --cpu 16 --timeout 10s
stress-ng --cpu 16 --timeout 10s
Zeile 50: Zeile 50:
0.5 Kerne
0.5 Kerne
{{BML|code=
{{BML|code=
docker run --cpu 0.5 --rm -it dockerschulung/resource_limiting_base:1.0 bash
docker run --cpus 0.5 --rm -it dockerschulung/resource_limiting_base:1.0 bash
# stress-ng cpu test (16 cores) for 10 seconds
# stress-ng cpu test (16 cores) for 10 seconds
stress-ng --cpu 16 --timeout 10s
stress-ng --cpu 16 --timeout 10s
}}
}}

Version vom 17. April 2024, 18:14 Uhr

Im folgenden soll die Limitierung der Ressourcen für Container erläutert werden, diese Informationen Beziehen sich auf das Host System GNU/Linux.

Eine vollständige Liste der Option zur Ressourcen Limitierung von CPU, Memory und GPU findet sich hier.

Während aller Tests docker stats in eigenem Terminal öffnen.

Testimage

Dockerfile

Inhalt in Datei Dockerfile

FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y memtester pv

Building Image

docker build . -t dockerschulung/resource_limiting_base:1.0

Memory

512mb RAM, keine Möglichkeit zum swappen

docker run --memory 512m --memory-swap 512m --rm -it dockerschulung/resource_limiting_base:1.0 bash
# tail will be filled with up to 3000mb at a rate of 100mb/s
head -c 3000m /dev/zero | pv -L 100m | tail

512mb RAM, 1gb swap Speicher

docker run --memory 512m --memory-swap 1536m --rm -it dockerschulung/resource_limiting_base:1.0 bash
# tail will be filled with up to 3000mb at a rate of 100mb/s
head -c 3000m /dev/zero | pv -L 100m | tail

CPU

1 Kern

docker run --cpus 1 --rm -it dockerschulung/resource_limiting_base:1.0 bash
# stress-ng cpu test (16 cores) for 10 seconds
stress-ng --cpu 16 --timeout 10s

2 Kerne

docker run --cpus 2 --rm -it dockerschulung/resource_limiting_base:1.0 bash
# stress-ng cpu test (16 cores) for 10 seconds
stress-ng --cpu 16 --timeout 10s

0.5 Kerne

docker run --cpus 0.5 --rm -it dockerschulung/resource_limiting_base:1.0 bash
# stress-ng cpu test (16 cores) for 10 seconds
stress-ng --cpu 16 --timeout 10s