如何清除Docker任务历史记录

问题描述:

以群体模式运行docker时,随着docker服务的更新,过去任务的历史记录也会累积。运行 docker node ps 显示任务日志。

When running docker in swarm mode, a history of past tasks accumulate as docker services are updated. Running docker node ps displays the log of tasks.

如何清除此日志而不删除

How do I clear this log without removing the service?

您可以通过运行以下命令来调整swarm的历史记录限制:

You can adjust the history limit in swarm by running:

docker swarm update --task-history-limit=1

将仅保留一个先前的任务,而不保留默认任务5。有关更多详细信息,请参见cli文档: https://docs.docker.com/engine/reference/commandline/swarm_update/

Which will only keep one previous task instead of the default 5. See the cli docs for more details: https://docs.docker.com/engine/reference/commandline/swarm_update/