Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第七章 nginx容器启动执行top命令失败 #95

Open
lin-coco opened this issue Mar 12, 2024 · 0 comments
Open

第七章 nginx容器启动执行top命令失败 #95

lin-coco opened this issue Mar 12, 2024 · 0 comments

Comments

@lin-coco
Copy link

lin-coco commented Mar 12, 2024

$ ./mydocker run -d --name mynginx nginx top -b

书中使用了这样的命令去启动nginx容器,这里一开始我也默认容器内会有top命令,然后就启动过后使用ps -ef | grep "pid"找不到这个容器进程,没有任何报错日志,我一直怀疑是我2c2g的阿里云内存不足,被强制kill了(因为之前有这个情况出现),所以就一直往这方面想。最后我进入docker容器里才发现没有top这个命令(其实./mydocker logs也打印出“exec: "top": executable file not found in $PATH”不过我没发现)

$ docker exec -it b1dc8cf0002a /bin/bash
root@b1dc8cf0002a:/# top
bash: top: command not found

之后我就换成了下面这样来启动,启动成功

$ ./mydocker run -d --name mynginx nginx sh -c "while true; do sleep 1000;done"
$ # 停止要使用-9
$ ./mydocker stop -f mynginx

在这里希望给大家提个醒,看看pull的镜像当中有没有需要执行的命令

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant