标签:端口 code ted 时间 cond 通过 and commit creat
[root@test32 ~]# docker run nginx /bin/sh -c "while true; do echo hello world; sleep 1; done"
hello world
hello world
hello world
hello world
[root@test32 ~]# docker run -d nginx /bin/sh -c "while true; do echo hello world; sleep 1; done"
2939156e31bb2913453aaa424214376c382aabef2bf1903e723e2ad9f6330e35
[root@test32 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2939156e31bb nginx "/bin/sh -c ‘while..." 17 seconds ago Up 15 seconds 80/tcp youthful_hodgkin
此时用 docker logs 来查看日志
[root@test32 ~]# docker logs -f -t 293915
2018-12-26T10:34:40.558068000Z hello world
2018-12-26T10:34:41.559143000Z hello world
2018-12-26T10:34:42.560398000Z hello world
2018-12-26T10:34:43.561626000Z hello world
2018-12-26T10:34:44.562831000Z hello world
2018-12-26T10:34:45.564119000Z hello world
-f 跟踪实时日志
--since string 显示自某个timestamp之后的日志,或相对时间,如42m(即42分钟)
--tail string 从日志末尾显示多少行日志, 默认是all
-t 显示时间戳
--until string 显示自某个timestamp之前的日志,或相对时间
[root@test32 ~]# docker logs -f -t --tail=10 293915
[root@test32 ~]# docker logs -t --since="2018-12-26T10:48Z" 293915 2018-12-26T10:48:00.605556000Z hello world
2018-12-26T10:48:01.607088000Z hello world
2018-12-26T10:48:02.608282000Z hello world
2018-12-26T10:48:03.609575000Z hello world
2018-12-26T10:48:04.610942000Z hello world
stop
[root@test32 ~]# docker stop 293915
293915
[root@test32 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2939156e31bb nginx "/bin/sh -c ‘while..." 16 minutes ago Exited (137) 14 seconds ago youthful_hodgkin
通过docker的两个参数 -i -t,让docker运行的容器实现"对话"的能力
标签:端口 code ted 时间 cond 通过 and commit creat
原文地址:http://blog.51cto.com/12390045/2335677