Docker logs 命令

[root@docker01 ~]# 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 "all")/仅列出最新N条容器日志
  -t, --timestamps     Show timestamps/显示时间戳
[root@docker03 ~]# docker ps -a
CONTAINER ID        IMAGE                                                                                                    COMMAND                  CREATED             STATUS                    PORTS               NAMES
b2d18062bc24        docker01.lo:5000/api-gateway@sha256:016f07159faeacadd5fc8719776382caf39f0b8ffeb276ed9bbecb2adfa8ce75     "java -jar /api-ga..."   4 days ago          Up 4 days                                     api-gateway.1.1q9ww6opn8mppbwmozaoadfyx
e6a7d71258a6        docker01.lo:5000/api-gateway@sha256:68048a64ae47de39e83be73fa0fc1847c42cfe034b084b89b1de19ff029cd9ab     "java -jar /api-ga..."   4 days ago          Exited (143) 4 days ago                       api-gateway.1.zeqoq5h3jub6lvqqem4t3phby
231b17a107dc        docker01.lo:5000/api-gateway@sha256:68048a64ae47de39e83be73fa0fc1847c42cfe034b084b89b1de19ff029cd9ab     "java -jar /api-ga..."   4 days ago          Exited (1) 4 days ago                         api-gateway.1.srz8ufj0eq0ble1r2smyfoeht
d49702881b38        docker01.lo:5000/api-gateway@sha256:86b6401dc4b1f9eb89c8c9e6f0acd6aa29f0f4b9572598d4b50cecf3bbdac2ed     "java -jar /api-ga..."   4 days ago          Exited (143) 4 days ago                       api-gateway.1.lw48xff6nb2k2e1ijf0oladsf
ec66c83e978c        docker01.lo:5000/api-gateway@sha256:86b6401dc4b1f9eb89c8c9e6f0acd6aa29f0f4b9572598d4b50cecf3bbdac2ed     "java -jar /api-ga..."   4 days ago          Exited (1) 4 days ago                         api-gateway.1.ftfl0sl3rtj5qyvz3paifo3ty
f6a5091e25ad        docker01.lo:5000/web-service@sha256:188f8365c115fb14c7b3046a58d7437fa0cf057fc558ab6bcb19d4960728a969     "java -jar /web-se..."   4 days ago          Up 4 days                                     web-service.2.vjg9uq3tbey8lkxv6l2jlkkdw
b3af5cc16203        docker01.lo:5000/web-gateway@sha256:7b841751783370b89dfde757d36ff875b2d1b01a18c4d5a13e80d33c043e7f2c     "java -jar /web-ga..."   4 days ago          Up 4 days                                     web-gateway.1.csnp2ccie9rv9ynxdg92part6
531e6607245b        docker01.lo:5000/web-gateway@sha256:7b841751783370b89dfde757d36ff875b2d1b01a18c4d5a13e80d33c043e7f2c     "java -jar /web-ga..."   4 days ago          Exited (1) 4 days ago                         web-gateway.1.h9f76ung8d4gi5u1mv9pdwy9r
58919d6b304a        docker01.lo:5000/eureka-server@sha256:55922af71b78ce43fc2a9f2f78ab1f6b17f41e162b858937a744876dd3952c77   "java -jar /eureka..."   7 days ago          Up 7 days                                     eureka-server.1.jbhrlk2lsb75xy41n4dcjvsia
[root@docker03 ~]# docker logs -f  --tail=10 api-gateway.1.1q9ww6opn8mppbwmozaoadfyx
2017-07-11 02:27:47.111  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=null, version=null, state=null
2017-07-11 02:30:48.354  INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2017-07-11 02:32:47.148  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://10.0.0.6:7001/
2017-07-11 02:32:47.211  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=null, version=null, state=null
2017-07-11 02:35:48.355  INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2017-07-11 02:37:47.252  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://10.0.0.6:7001/
2017-07-11 02:37:47.321  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=null, version=null, state=null
2017-07-11 02:40:48.355  INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2017-07-11 02:42:47.357  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://10.0.0.6:7001/
2017-07-11 02:42:47.418  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=null, version=null, state=null

查看容器api-gateway.1.1q9ww6opn8mppbwmozaoadfyx从2017年7月10日后的最新10条日志。

[root@docker03 ~]# docker logs -f --since="2017-07-10" --tail=10 api-gateway.1.1q9ww6opn8mppbwmozaoadfyx
2017-07-11 02:30:48.354  INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2017-07-11 02:32:47.148  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://10.0.0.6:7001/
2017-07-11 02:32:47.211  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=null, version=null, state=null
2017-07-11 02:35:48.355  INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2017-07-11 02:37:47.252  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://10.0.0.6:7001/
2017-07-11 02:37:47.321  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=null, version=null, state=null
2017-07-11 02:40:48.355  INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2017-07-11 02:42:47.357  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://10.0.0.6:7001/
2017-07-11 02:42:47.418  INFO 1 --- [nfoReplicator-0] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config, profiles=[dev], label=null, version=null, state=null
2017-07-11 02:45:48.357  INFO 1 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration

 

posted on 2017-07-11 10:49  vijayfly  阅读(2220)  评论(0编辑  收藏  举报

导航