答案1
你可以通过管道它抗过滤器:
docker stats --format "{{ .Name }},{{ .MemUsage }},{{ .MemPerc }},{{ .CPUPerc }}" | ansifilter > /home/test.txt
请注意,它将/home/test.txt
包含多行。它看起来像这样:
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,656KiB / 7.476GiB,0.01%,0.00%
alpine,528KiB / 7.476GiB,0.01%,0.00%
alpine,528KiB / 7.476GiB,0.01%,0.00%
alpine,528KiB / 7.476GiB,0.01%,0.03%
alpine,528KiB / 7.476GiB,0.01%,0.03%
alpine,528KiB / 7.476GiB,0.01%,0.02%