Can't start httpd service in docker image
13,314
You are doing completely wrong. RUN
command will be executed only during build. You should use something like the following
FROM centos:6.6
RUN yum install -y httpd
EXPOSE 80
ENTRYPOINT ["/usr/sbin/httpd", "-D", "FOREGROUND"]
Also you can take a look at official apache Dockerfile
Related videos on Youtube
Author by
Glasnhost
Updated on September 18, 2022Comments
-
Glasnhost almost 2 years
I have the following Dockerfile that should start a centos machine and install httpd:
FROM centos:centos6.6 RUN yum install -y httpd RUN chkconfig httpd on; RUN /etc/init.d/httpd start EXPOSE 80 CMD ["/bin/bash"]
I build the image:
docker build --no-cache -t centos_http .
The build says:
... Step 4/6 : RUN /etc/init.d/httpd start ---> Running in 0766e84ec292 Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2 for ServerName [ OK ] ... Successfully built 5380a0bacdfb
But if I run the image:
docker run -p 8090:80 -it 5380 [root@eda7400a46a9 /]# ps -ef | grep httpd | grep -v grep [root@eda7400a46a9 /]#
httpd is not running! if I execute manually /etc/init.d/httpd start, inside the image, it works fine...