摘取自learning docker.pdf
docker早起是没有内置debug功能的,而debug多是社区的开源贡献者的,后来docker内置了这项功能
1.exec
Now, it is not necessary to log in to run the SSH daemon in the container.
使用exec登录
root@VM-87-81-debian:~# clear
root@VM-87-81-debian:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
be0967ec7e63 busybox:latest "/bin/sh" 22 hours ago Up 22 hours datavol
c596bd8f836b diancloud/ghost:0.6.3-zh "bash /ghost/ghost-st" 43 hours ago Up 43 hours 0.0.0.0:80->2368/tcp diancloud-ghost
root@VM-87-81-debian:~# docker exec -it be sh
/ #
/ #
注意:
It is recommended that you use the docker exec command only for monitoring
and diagnostic purposes, and I personally believe in the concept of one process per
container, which is one of the best practices widely accentuated.
2.ps
这是可以查看容器的state,不过多介绍
3.上面是需要在容器里面才能执行的,我们也可以不登录主机情况下直接使用top
root@VM-87-81-debian:~# docker top be
UID PID PPID C STIME TTY TIME CMD
root 31729 31711 0 Jun24 pts/0 00:00:00 /bin/sh
也可以在容器里面执行top查看更加详细的report
4.stats
stats用来查看该容器占用主机的cpu,内容等资源情况
The Docker stats command provides you with the capability to view the memory, CPU, and the network usage of a container from a Docker host machine