docker查看日志

本文介绍了如何使用Dockerlogs命令及其选项,包括实时输出(-f),按时间筛选(--since,--until),显示尾部日志(--tail),和时间戳显示(--timestamps)等,帮助用户高效管理容器日志。
摘要由CSDN通过智能技术生成
docker logs
[root@xxxx xxxx]# docker logs --help

Usage:	docker logs [OPTIONS] CONTAINER

Fetch the logs of a container

Options:
      --details        Show extra details provided to logs
  -f, --follow         Follow log output
      --since string   Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
      --tail string    Number of lines to show from the end of the logs (default "all")
  -t, --timestamps     Show timestamps
      --until string   Show logs before a timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
[root@xxxx xxxx]# 

OPTIONS常用

  • -f:实时输出日志
  • --since:show logs since timestamp
  • --tail:显示最后几行日志,如--tail=200(最后200行日志)
  • --until:show logs before a timestamp
通过时间筛选日志
docker logs --since "2024-04-29" --until "2024-04-30" [docker容器名或容器id]

sinceuntil选项可分开使用

查看某个日期至今所有日志,并持续输出
docker logs -f --since "2024-04-30" [docker容器名称或容器id]

f选项为实时输出

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值