1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| [root@test ~]# docker pull lorel/docker-stress-ng Using default tag: latest Trying to pull repository docker.io/lorel/docker-stress-ng ... latest: Pulling from docker.io/lorel/docker-stress-ng c52e3ed763ff: Pull complete a3ed95caeb02: Pull complete 7f831269c70e: Pull complete Digest: sha256:c8776b750869e274b340f8e8eb9a7d8fb2472edd5b25ff5b7d55728bca681322 Status: Downloaded newer image for docker.io/lorel/docker-stress-ng:latest # 下载压测镜像stress [root@test ~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/lorel/docker-stress-ng latest 1ae56ccafe55 2 years ago 8.1 MB [root@test ~]# docker run --name stress -it --rm lorel/docker-stress-ng --help stress-ng, version 0.03.11 ... ... Example: stress-ng --cpu 8 --io 4 --vm 2 --vm-bytes 128M --fork 4 --timeout 10s
Note: Sizes can be suffixed with B,K,M,G and times with s,m,h,d,y # 查看使用帮助 [root@test ~]# docker run --name stress -it --rm -m 256m lorel/docker-stress-ng --vm 2 stress-ng: info: [1] defaulting to a 86400 second run per stressor stress-ng: info: [1] dispatching hogs: 2 vm # -m表示给这个容器使用多少内存。--vm表示启动几个进程对内存进行压测,--vm-bytes表示每个进程可以使用的内存数,默认是256m,这里使用默认值,所以没有设置。 [root@test ~]# docker top stress UID PID PPID C STIME TTY TIME CMD root 2389 2375 0 16:21 pts/1 00:00:00 /usr/bin/stress-ng --vm 2 root 2413 2389 0 16:21 pts/1 00:00:00 /usr/bin/stress-ng --vm 2 root 2415 2389 0 16:21 pts/1 00:00:00 /usr/bin/stress-ng --vm 2 root 2440 2415 99 16:21 pts/1 00:00:02 /usr/bin/stress-ng --vm 2 # 打开另一终端查看容器启动的进程 [root@test ~]# docker stats CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS d07a7a5544ca 6.19% 255.9 MiB / 256 MiB 99.96% 648 B / 648 B 17.1 GB / 49.3 GB 5 # 查看容器的实时使用情况,因为设置了容器可用的内存数,所以不会超过256M。
|