浏览代码

fix apache2 issue on container restart

SiM 6 年之前
父节点
当前提交
5104d74921
共有 2 个文件被更改,包括 13 次插入1 次删除
  1. 5 1
      docker/apache-php/Dockerfile
  2. 8 0
      docker/apache-php/start-apache.sh

+ 5 - 1
docker/apache-php/Dockerfile

@@ -20,7 +20,11 @@ RUN a2enmod headers
 # PHP
 RUN php5enmod imagick
 
-CMD ["/usr/sbin/apache2ctl", "-D" ,"FOREGROUND"]
+# Simple startup script to avoid some issues observed with container restart 
+ADD start-apache.sh /start-apache.sh
+RUN chmod -v +x /start-apache.sh
+
+CMD ["/start-apache.sh"]
 
 EXPOSE 80
 EXPOSE 443

+ 8 - 0
docker/apache-php/start-apache.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Make sure we're not confused by old, incompletely-shutdown httpd
+# context after restarting the container.  httpd won't start correctly
+# if it thinks it is already running.
+rm -rf /run/apache2/*
+
+exec /usr/sbin/apache2ctl -D FOREGROUND