跳转至

Docker logs 命令


2016-06-08 by dongnan

举个栗子

使用 docker logs 选项,查看容器中输出的日志。

# 执行命令
docker logs -f 7c06cbf77a43

Initializing database
2016-05-20T02:35:55.404765Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-05-20T02:35:55.793886Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
#...省略
2016-05-20T02:36:23.975043Z 0 [Note] mysqld (mysqld 5.7.12) starting as process 1 ...
#...省略
Version: '5.7.12'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

可以使用tail参数输出最后指定的日志行数

docker logs zabbix-server-mysql --tail 100

命令参数

命令帮助

# 执行命令
docker logs --help

Usage:    docker logs [OPTIONS] CONTAINER

Fetch the logs of a container

 -f, --follow=false        Follow log output
  --help=false              Print usage
  --since=                  Show logs since timestamp
  -t, --timestamps=false    Show timestamps
  --tail=all                Number of lines to show from the end of the logs






回到页面顶部