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

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 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...


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


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

Also you can take a look at official apache Dockerfile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.