docker diff/events命令

diff是用来比较容器和原镜像有什么区别,类似于git diff和status,这个直接用就行了,没太多好说的,比如刚才我们用docker cp复制了几份文件进入了ubuntu这个容器,看看有没有什么不同

[[email protected] ~]# docker diff ubuntu
C /home
A /home/rtest.txt
A /home/rtest2.txt
A /home/test.txt

events是用来实时查看输出的,类似于tail -f ,所以你得重新打开个终端。比如,我们先start ubuntu_2,看看发生什么

[[email protected] ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be9d5c6f2a25 ubuntu:14.04 "/bin/bash" 4 seconds ago Up 3 seconds ubuntu
dca3d42e5e3e ubuntu:14.04 "/bin/bash" 8 minutes ago Exited (0) 2 minutes ago ubuntu
7103a04f97d3 ubuntu:14.04 "/bin/bash" 3 hours ago Up 3 hours ubuntu
[[email protected] ~]# docker start ubuntu_2 
ubuntu_2

同时看下另一个窗口

[[email protected] ~]# 
[[email protected] ~]# docker events 
2019-07-04T22:15:40.528401428+08:00 network connect 05475ea368337254dea611bfff0a86005befb5ea3da6e3bb6b7b3d40bbe4e33e (container=dca3d42e5e3ef9feaf0b0a1fb2a54700e8fe026b757845ffe36e3ca30e846f5a, name=bridge, type=bridge)
2019-07-04T22:15:40.957176678+08:00 container start dca3d42e5e3ef9feaf0b0a1fb2a54700e8fe026b757845ffe36e3ca30e846f5a (image=ubuntu:14.04, name=ubuntu_2)
2019-07-04T22:15:41.056997438+08:00 container die dca3d42e5e3ef9feaf0b0a1fb2a54700e8fe026b757845ffe36e3ca30e846f5a (exitCode=0, image=ubuntu:14.04, name=ubuntu_2)
2019-07-04T22:15:41.110200252+08:00 network disconnect 05475ea368337254dea611bfff0a86005befb5ea3da6e3bb6b7b3d40bbe4e33e (container=dca3d42e5e3ef9feaf0b0a1fb2a54700e8fe026b757845ffe36e3ca30e846f5a, name=bridge, type=bridge)

重新启动容器ubuntu_4,看看发生了什么

[[email protected] ~]# docker run -itd --name ubuntu_4 ubuntu:14.04
5fb08267227e4a81d3cde7e9e0ffddcca18bba30f341af01ba420e3b18d8df47

开另一个终端

[[email protected] ~]# docker events 
2019-07-04T22:20:45.807362786+08:00 container create 5fb08267227e4a81d3cde7e9e0ffddcca18bba30f341af01ba420e3b18d8df47 (image=ubuntu:14.04, name=ubuntu_4)
2019-07-04T22:20:45.839129624+08:00 network connect 05475ea368337254dea611bfff0a86005befb5ea3da6e3bb6b7b3d40bbe4e33e (container=5fb08267227e4a81d3cde7e9e0ffddcca18bba30f341af01ba420e3b18d8df47, name=bridge, type=bridge)
2019-07-04T22:20:46.165168069+08:00 container start 5fb08267227e4a81d3cde7e9e0ffddcca18bba30f341af01ba420e3b18d8df47 (image=ubuntu:14.04, name=ubuntu_4)

总结一下,就是docker events输出的是docker 服务端的日志,而不是容器本身的日志,不要和容器日志混为一谈。

此条目发表在Docker分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注