Docker CentOS image does not auto start httpd Docker CentOS image does not auto start httpd docker docker

Docker CentOS image does not auto start httpd


You need to run apache (httpd) directly - you should not use init.d script.

Two options:

  1. you have to run apache in foreground: /usr/sbin/apache2 -DFOREGROUND ... (or /usr/sbin/httpd in CentOS)
  2. you have to start all services (including apache configured as auto-run) by executing /sbin/init as entrypoint.


Add this line in the bottom of your Dockerfile to run Apache in the foreground on CentOS

ENTRYPOINT ["/usr/sbin/httpd", "-D", "FOREGROUND"]


Simple Dockerfile to run httpd on centOS

FROM centos:latestRUN yum update -yRUN yum install httpd -yENTRYPOINT ["/usr/sbin/httpd","-D","FOREGROUND"]

Commands for building images and running container

Build

docker build . -t chttpd:latest

Running container using new image

docker container run  -d -p 8000:80 chttpd:latest