docker 容器调试工具

摘取自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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值