Docker没有运行/显示长时间运行的进程

时间:2014-04-04 16:51:34

标签: docker

为什么会这样?

$ docker pull ubuntu
# stuff...
$ docker run ubuntu apt-get install -y tree
Reading package lists...
$ 

出现死亡。 $?是0。 ping有一个类似的问题:

$ docker run ubuntu ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=61 time=24.2 ms
^C
 $ 

请注意,ping不会在^ C上转储有关丢失数据包的常用信息。

将ping保持开启几分钟不会导致文本突然转储(就像我在刷新缓冲区时所期望的那样)。

这里发生了什么?

1 个答案:

答案 0 :(得分:0)

ping的案例对我来说很好(ubuntu 13.10,Docker版本0.9.1,版本3600720):

$ sudo docker run ubuntu ping google.com
PING google.com (173.194.32.166) 56(84) bytes of data.
64 bytes from 173.194.32.166: icmp_req=1 ttl=55 time=19.1 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 19.073/19.116/19.159/0.043 ms

您可以尝试以交互模式运行容器

sudo docker run -i -t  ubuntu /bin/bash

在那里玩pingapt-get。 也许apt-get只是执行一些长时间运行的进程(更新包列表)。所以你可以在后台运行它并检查apt-get对top,htop等的确切作用。