这是我为在 centos
上安装 httpd
而创建的 Dockerfile
:
#Installing HTTPD
FROM centos:latest
MAINTAINER xxx@gmail.com
RUN yum install -y httpd
EXPOSE 80
#ENTRYPOINT ["systemctl"]
ENTRYPOINT ["/usr/sbin/httpd"]
构建后,当我运行容器时,我可以看到太多 httpd
进程在此容器内运行:
docker run -d -p 80:80 httpd:4.0 -DFOREGROUND
Docker top
命令的输出:
UID PID PPID C STIME TTY TIME CMD
root 2457 2443 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2474 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2475 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2476 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2477 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2478 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2491 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2492 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
apache 2493 2457 0 04:26 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
root 2512 2500 0 04:27 pts/0 00:00:00 /bin/bash
apache 2532 2457 0 04:27 ? 00:00:00 /usr/sbin/httpd -DFOREGROUND
请告诉我为什么有这么多 httpd 进程在运行以及如何只有一个 PID 为 1 的进程?
最佳答案
Apache 运行多个进程以准备好快速捕获客户端请求,因为生成服务器进程很慢,因此最好在请求到来时准备一个进程。
您可以通过StartServers在httpd.conf
中配置它们的号码, MinSpareServers , MaxSpareServers和 ServerLimit指令。
关于linux - Docker 容器中运行多个 httpd 进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45808978/