This post was updated 823 days ago and some of the ideas may be out of date.

问题描述

今天在 docker 中部署完 nginx 后,想看下是否已经启动成功,于是想通过 ps 命令查看进程:

ps -ef|grep 'nginx'

结果报了如下错误:

root@extand-6b8689c85-zwggj:/# ps -ef|grep 'nginx'
bash: ps: command not found

解决方法

出现 bash: ps: command not found 错误的原因是,由于该 nginx 镜像 没有打包 ps 命令,我们可以使用如下命令安装:

apt-get update && apt-get install procps

稍等片刻安装成功后,再执行 ps 命令,已不再报错,具体如下:

root@extand-6b8689c85-zwggj:/# ps -ef|grep 'nginx'
root         1     0  0 01:45 ?        00:00:00 nginx: master process nginx -g daemon off;
nginx       31     1  0 01:45 ?        00:00:00 nginx: worker process
root       411    87  0 05:59 pts/3    00:00:00 grep nginx

原文链接:https://www.lervor.com/archives/160/