Error when dockerfile creates apache image

Error report phenomenon:

When running the h container with the new httpd image, the port is not mapped successfully
[root@localhost apache]# docker run -d -p 8080:80 httpd:centos
Insert picture description here

Solution:

When the blogger went back to check the executed script run.sh and found

[root@localhost apache]# vim run.sh
#!/bin/bash 
rm -rf /run/httpd*     ##这样就是将httpd的所有文件删除了,是错误的
exec /usr/sbin/apachectl -D FOREGROUND

The correct one should be

[root@localhost apache]# vim run.sh
#!/bin/bash 
rm -rf /run/httpd/*     ##应该是将httpd的下的子文件(包括PID文件等)删除
exec /usr/sbin/apachectl -D FOREGROUND


Insert picture description here
You can also visit the website after re-run
Insert picture description here

Guess you like

Origin blog.csdn.net/Cpureman/article/details/108702225