赞
踩
docker日志分为两大类,引擎日志和容器日志
一、引擎日志
在centos系统上,docker的引擎日志交给了systemd进行管理,查看引擎日志,使用如下命令:
- [root@Python ~]# journalctl -u docker
- [root@Python ~]# journalctl -u docker | tail -100
二、容器日志
1
使用 docker logs 查看容器日志;
语法:
- docker logs [OPTIONS] CONTAINER
-
- Options:
- --details 显示更多的信息
- -f, --follow 跟踪实时日志
- --tail string 从日志末尾显示多少行日志, 默认是all
- -t, --timestamps 显示时间戳
- --since string 显示自某个timestamp之后的日志,或相对时间,如42m(即42分钟)
- --until string 显示自某个timestamp之前的日志,或相对时间,如42m(即42分钟)
1)动态查看容器日志,只输出最后100行;
docker logs -f -t --tail=100 CONTAINER_ID
2)查看最近30分钟的日志
docker logs --since 30m CONTAINER_ID
3)查看某时间段日志
docker logs -t --since="2019-04-01T13:23:37" --until "2018-04-01T15:23:37" CONTAINER_ID
2
使用 docker-compose logs 查看容器的编排日志;
语法:
- docker-compose logs [options] [SERVICE...]
-
- Options:
- --no-color 单色输出
- -f, --follow 跟踪实时日志
- --tail string 从日志末尾显示多少行日志, 默认是all
- -t, --timestamps 显示时间戳
3
使用 docker service logs 查看swarm集群的服务日志;
语法:
- docker service logs [OPTIONS] SERVICE|TASK
-
- Options:
- --details
- -f, --follow
- --since string
- --tail string
- -t, --timestamps
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。