簡體   English   中英

如何找到停止 Docker 容器的用戶

[英]How to Find The User Who Stopped Docker Container

我想知道停止 docker 容器的用戶是什么。

我的服務器上有幾個用戶帳戶。 我懷疑其中一個有時會停止容器。

如何找到執行此操作的用戶?

您可以使用su -c history username檢查su -c history username命令歷史記錄,我不知道您有多少用戶,但您可以遍歷它們並 grep 獲取關閉 docker 容器的命令。

您可以安裝GNU Accounting Utilities ,以便能夠查看用戶執行的命令:

#centos
yum install psacct
# ubuntu: 
apt-get install acct

#Also make sure that the cooresponding service is enabled: 
/etc/init.d/psacct status

然后,在您意識到容器停止后執行:

lastcomm --command docker
# or
lastcomm --command kill

查看哪個執行了上述命令。

您可以將上述內容與:

 docker container logs <name-of-the-container>

查看容器停止的確切時間。 (例如,您可能會在日志上看到一條消息:“停止服務..”)並將其與lastcomm輸出匹配。

上述軟件包附帶的其他有用命令: saac

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM