Docker CentOS图像不会自动启动httpd [英] Docker CentOS image does not auto start httpd
问题描述
docker运行-t -i -p 80:80我/ httpd / bin / bash
然后手动启动Apache
code> service httpd start
但是,我无法让httpd在运行时自动启动
docker run -d -p 80:80 my / httpd
Apache将启动然后容器存在。我已经在我的码头文件中尝试了一堆不同的 CMD
CMD /etc/init.d/httpd start
CMD [servicehttpdstart]
CMD [/ bin / bash,/etc/init.d/httpd start ]
ENTRYPOINT /etc/init.d/httpd CMD start
CMD ./start.sh
start.sh是
#!/ bin / bash
/etc/init.d/ httpd start
但是,apache启动后,每个停泊点的实例都将存在
我缺少一些非常明显的东西?
你需要直接运行apache(httpd)不应该使用init.d脚本。
两个选项:
- 你必须在前台运行apache:
/ usr / sbin / apache2 -DFOREGROUND ...
(或CentOS中的/ usr / sbin / httpd) - 您必须启动所有服务(包括配置为自动运行的apache)通过执行
/ sbin / init
作为入口点。
看到这个漂亮的帖子: http://www.kstaken.com/blog/2013/07/06/how-to-run-apache-under-docker/
I'm trying to run a simple Docker image with Apache and a PHP program. It works fine if I run
docker run -t -i -p 80:80 my/httpd /bin/bash
then manually start Apache
service httpd start
however I cant get httpd to start automatically when running
docker run -d -p 80:80 my/httpd
Apache will startup then container exists. I have tried a bunch of different CMD
s in my docker file
CMD /etc/init.d/httpd start
CMD ["service" "httpd" "start"]
CMD ["/bin/bash", "/etc/init.d/httpd start"]
ENTRYPOINT /etc/init.d/httpd CMD start
CMD ./start.sh
start.sh is
#!/bin/bash
/etc/init.d/httpd start
However every-time docker instance will exist after apache starts
Am I missing something really obvious?
You need to run apache (httpd) directly - you should not use init.d script.
Two options:
- you have to run apache in foreground:
/usr/sbin/apache2 -DFOREGROUND ...
(or /usr/sbin/httpd in CentOS) - you have to start all services (including apache configured as auto-run) by executing
/sbin/init
as entrypoint.
See this nice post: http://www.kstaken.com/blog/2013/07/06/how-to-run-apache-under-docker/
这篇关于Docker CentOS图像不会自动启动httpd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!