Docker查看日志常用参数

在实际使用docker的过程中,我们经常需要查看一个docker内部的日志来查看程序是否正常运行以及排查错误等,所以对于docker容器如何来查看日志是一项非常基本且重要的事情。

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
      --help           Print usage
      --since string   Show logs since timestamp
      --tail string    Number of lines to show from the end of the logs (default "al
  -t, --timestamps     Show timestamps

这上面展示的就是常用的参数:

  • –details 显示额外的信息
  • -f或者–follow显示实时信息
  • –since 加上时间戳查找特定时间的日志
  • –tail 加上整数查看最新多少行的日志
  • -t或者–timestamps 表示显示时间戳

示例的命令如下:

docker logs -f -t --since="2020-02-03" --tail=10 mqtt_mqtt_1

上面就是查看容器mqtt_mqtt_1从2020年2月3号开始最新10行的日志.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值