Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有可能 - 如果是的话,如何 - 拥有由“docker ps”类似的 top/htop 实用程序打印的当前 Docker 容器的自刷新视图?
使用watch:
watch
watch docker ps
看man watch
man watch
几个选项:
您可以尝试 command docker stats,它将为您提供有关当前正在运行的容器 id、cpu%、内存等的一些详细信息。与top/htop您要求的类似的东西。
docker stats
top/htop
命令docker top CONTAINER [ps OPTIONS]:显示容器的运行进程。
docker top CONTAINER [ps OPTIONS]
还有一些可用的应用程序可以很好地了解您的 docker 生态系统。例如-Kitematic , Kevana
作为 watch 的替代方法,显示了一个别名来循环 docker stats(watch:默认情况下可能并不总是可用)
这将创建一个 bash 别名“ds”
alias ds='while true; do TEXT=$(docker stats --no-stream $(docker ps --format={{.Names}})); sleep 0.1; clear; echo "$TEXT"; done'
来自:https ://github.com/docker/docker/issues/20973