diff --git a/5.6/alpine3.8/cli/Dockerfile b/5.6/alpine3.8/cli/Dockerfile
index 2445411aa..029558614 100644
--- a/5.6/alpine3.8/cli/Dockerfile
+++ b/5.6/alpine3.8/cli/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/5.6/alpine3.8/fpm/Dockerfile b/5.6/alpine3.8/fpm/Dockerfile
index 58856feda..cfa59596b 100644
--- a/5.6/alpine3.8/fpm/Dockerfile
+++ b/5.6/alpine3.8/fpm/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/5.6/alpine3.8/zts/Dockerfile b/5.6/alpine3.8/zts/Dockerfile
index 725759fa9..c16af9a02 100644
--- a/5.6/alpine3.8/zts/Dockerfile
+++ b/5.6/alpine3.8/zts/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/5.6/jessie/apache/Dockerfile b/5.6/jessie/apache/Dockerfile
index 0a5d894d1..a0c3fcaed 100644
--- a/5.6/jessie/apache/Dockerfile
+++ b/5.6/jessie/apache/Dockerfile
@@ -37,18 +37,22 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- apache2 \
- && rm -rf /var/lib/apt/lists/*
-
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends apache2; \
+ rm -rf /var/lib/apt/lists/*; \
\
# generically convert lines like
# export APACHE_RUN_USER=www-data
@@ -64,7 +68,6 @@ RUN set -eux; \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
- /var/www/html \
; do \
rm -rvf "$dir"; \
mkdir -p "$dir"; \
@@ -73,6 +76,9 @@ RUN set -eux; \
chmod 777 "$dir"; \
done; \
\
+# delete the "index.html" that installing Apache drops in here
+ rm -rvf /var/www/html/*; \
+ \
# logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
diff --git a/5.6/jessie/cli/Dockerfile b/5.6/jessie/cli/Dockerfile
index a930a1eba..2f2fb7508 100644
--- a/5.6/jessie/cli/Dockerfile
+++ b/5.6/jessie/cli/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/5.6/jessie/fpm/Dockerfile b/5.6/jessie/fpm/Dockerfile
index dc672e67d..6a9e52465 100644
--- a/5.6/jessie/fpm/Dockerfile
+++ b/5.6/jessie/fpm/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/5.6/jessie/zts/Dockerfile b/5.6/jessie/zts/Dockerfile
index 9634846ee..9a957c109 100644
--- a/5.6/jessie/zts/Dockerfile
+++ b/5.6/jessie/zts/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/5.6/stretch/apache/Dockerfile b/5.6/stretch/apache/Dockerfile
index 57f80c8bd..ef952ab79 100644
--- a/5.6/stretch/apache/Dockerfile
+++ b/5.6/stretch/apache/Dockerfile
@@ -37,18 +37,22 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- apache2 \
- && rm -rf /var/lib/apt/lists/*
-
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends apache2; \
+ rm -rf /var/lib/apt/lists/*; \
\
# generically convert lines like
# export APACHE_RUN_USER=www-data
@@ -64,7 +68,6 @@ RUN set -eux; \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
- /var/www/html \
; do \
rm -rvf "$dir"; \
mkdir -p "$dir"; \
@@ -73,6 +76,9 @@ RUN set -eux; \
chmod 777 "$dir"; \
done; \
\
+# delete the "index.html" that installing Apache drops in here
+ rm -rvf /var/www/html/*; \
+ \
# logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
diff --git a/5.6/stretch/cli/Dockerfile b/5.6/stretch/cli/Dockerfile
index c1d4c68e5..b137eeb06 100644
--- a/5.6/stretch/cli/Dockerfile
+++ b/5.6/stretch/cli/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/5.6/stretch/fpm/Dockerfile b/5.6/stretch/fpm/Dockerfile
index 9911027e2..b6e1bec2a 100644
--- a/5.6/stretch/fpm/Dockerfile
+++ b/5.6/stretch/fpm/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/5.6/stretch/zts/Dockerfile b/5.6/stretch/zts/Dockerfile
index 3fd0b9d57..e6d0597b6 100644
--- a/5.6/stretch/zts/Dockerfile
+++ b/5.6/stretch/zts/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/7.1/alpine3.8/cli/Dockerfile b/7.1/alpine3.8/cli/Dockerfile
index 3cf0f9841..9c8917865 100644
--- a/7.1/alpine3.8/cli/Dockerfile
+++ b/7.1/alpine3.8/cli/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/7.1/alpine3.8/fpm/Dockerfile b/7.1/alpine3.8/fpm/Dockerfile
index a983c7c87..c7cb7f355 100644
--- a/7.1/alpine3.8/fpm/Dockerfile
+++ b/7.1/alpine3.8/fpm/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/7.1/alpine3.8/zts/Dockerfile b/7.1/alpine3.8/zts/Dockerfile
index c406df9d8..fa1419859 100644
--- a/7.1/alpine3.8/zts/Dockerfile
+++ b/7.1/alpine3.8/zts/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/7.1/jessie/apache/Dockerfile b/7.1/jessie/apache/Dockerfile
index 6164d4895..cc292077b 100644
--- a/7.1/jessie/apache/Dockerfile
+++ b/7.1/jessie/apache/Dockerfile
@@ -37,18 +37,22 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- apache2 \
- && rm -rf /var/lib/apt/lists/*
-
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends apache2; \
+ rm -rf /var/lib/apt/lists/*; \
\
# generically convert lines like
# export APACHE_RUN_USER=www-data
@@ -64,7 +68,6 @@ RUN set -eux; \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
- /var/www/html \
; do \
rm -rvf "$dir"; \
mkdir -p "$dir"; \
@@ -73,6 +76,9 @@ RUN set -eux; \
chmod 777 "$dir"; \
done; \
\
+# delete the "index.html" that installing Apache drops in here
+ rm -rvf /var/www/html/*; \
+ \
# logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
diff --git a/7.1/jessie/cli/Dockerfile b/7.1/jessie/cli/Dockerfile
index 6622c7047..d834283c1 100644
--- a/7.1/jessie/cli/Dockerfile
+++ b/7.1/jessie/cli/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/7.1/jessie/fpm/Dockerfile b/7.1/jessie/fpm/Dockerfile
index 52decebda..a6f3c905c 100644
--- a/7.1/jessie/fpm/Dockerfile
+++ b/7.1/jessie/fpm/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/7.1/jessie/zts/Dockerfile b/7.1/jessie/zts/Dockerfile
index 5a4ee8a2c..27d2a5f1a 100644
--- a/7.1/jessie/zts/Dockerfile
+++ b/7.1/jessie/zts/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/7.1/stretch/apache/Dockerfile b/7.1/stretch/apache/Dockerfile
index cd557685a..675af7ea6 100644
--- a/7.1/stretch/apache/Dockerfile
+++ b/7.1/stretch/apache/Dockerfile
@@ -37,18 +37,22 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- apache2 \
- && rm -rf /var/lib/apt/lists/*
-
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends apache2; \
+ rm -rf /var/lib/apt/lists/*; \
\
# generically convert lines like
# export APACHE_RUN_USER=www-data
@@ -64,7 +68,6 @@ RUN set -eux; \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
- /var/www/html \
; do \
rm -rvf "$dir"; \
mkdir -p "$dir"; \
@@ -73,6 +76,9 @@ RUN set -eux; \
chmod 777 "$dir"; \
done; \
\
+# delete the "index.html" that installing Apache drops in here
+ rm -rvf /var/www/html/*; \
+ \
# logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
diff --git a/7.1/stretch/cli/Dockerfile b/7.1/stretch/cli/Dockerfile
index d37291f9f..9e3326b17 100644
--- a/7.1/stretch/cli/Dockerfile
+++ b/7.1/stretch/cli/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/7.1/stretch/fpm/Dockerfile b/7.1/stretch/fpm/Dockerfile
index f3af977b5..2f29b9b9f 100644
--- a/7.1/stretch/fpm/Dockerfile
+++ b/7.1/stretch/fpm/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/7.1/stretch/zts/Dockerfile b/7.1/stretch/zts/Dockerfile
index 523a1e7a4..e413e6c1b 100644
--- a/7.1/stretch/zts/Dockerfile
+++ b/7.1/stretch/zts/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/7.2/alpine3.8/cli/Dockerfile b/7.2/alpine3.8/cli/Dockerfile
index 842f08f1e..75e22a4e7 100644
--- a/7.2/alpine3.8/cli/Dockerfile
+++ b/7.2/alpine3.8/cli/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/7.2/alpine3.8/fpm/Dockerfile b/7.2/alpine3.8/fpm/Dockerfile
index 9c13b9fb9..634f06628 100644
--- a/7.2/alpine3.8/fpm/Dockerfile
+++ b/7.2/alpine3.8/fpm/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/7.2/alpine3.8/zts/Dockerfile b/7.2/alpine3.8/zts/Dockerfile
index 3e91783e1..bf6611a99 100644
--- a/7.2/alpine3.8/zts/Dockerfile
+++ b/7.2/alpine3.8/zts/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/7.2/stretch/apache/Dockerfile b/7.2/stretch/apache/Dockerfile
index 613f438cf..fb3173584 100644
--- a/7.2/stretch/apache/Dockerfile
+++ b/7.2/stretch/apache/Dockerfile
@@ -37,18 +37,22 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- apache2 \
- && rm -rf /var/lib/apt/lists/*
-
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends apache2; \
+ rm -rf /var/lib/apt/lists/*; \
\
# generically convert lines like
# export APACHE_RUN_USER=www-data
@@ -64,7 +68,6 @@ RUN set -eux; \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
- /var/www/html \
; do \
rm -rvf "$dir"; \
mkdir -p "$dir"; \
@@ -73,6 +76,9 @@ RUN set -eux; \
chmod 777 "$dir"; \
done; \
\
+# delete the "index.html" that installing Apache drops in here
+ rm -rvf /var/www/html/*; \
+ \
# logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
diff --git a/7.2/stretch/cli/Dockerfile b/7.2/stretch/cli/Dockerfile
index 4ed9ed940..936c4f276 100644
--- a/7.2/stretch/cli/Dockerfile
+++ b/7.2/stretch/cli/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/7.2/stretch/fpm/Dockerfile b/7.2/stretch/fpm/Dockerfile
index b820a71ac..6c88f468b 100644
--- a/7.2/stretch/fpm/Dockerfile
+++ b/7.2/stretch/fpm/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/7.2/stretch/zts/Dockerfile b/7.2/stretch/zts/Dockerfile
index 640abebf3..5d90ad720 100644
--- a/7.2/stretch/zts/Dockerfile
+++ b/7.2/stretch/zts/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/7.3/alpine3.8/cli/Dockerfile b/7.3/alpine3.8/cli/Dockerfile
index ea6b6c1ec..31a3f5060 100644
--- a/7.3/alpine3.8/cli/Dockerfile
+++ b/7.3/alpine3.8/cli/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/7.3/alpine3.8/fpm/Dockerfile b/7.3/alpine3.8/fpm/Dockerfile
index 845ea617d..bdf84abbe 100644
--- a/7.3/alpine3.8/fpm/Dockerfile
+++ b/7.3/alpine3.8/fpm/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/7.3/alpine3.8/zts/Dockerfile b/7.3/alpine3.8/zts/Dockerfile
index 7ed97c174..b6aef8d63 100644
--- a/7.3/alpine3.8/zts/Dockerfile
+++ b/7.3/alpine3.8/zts/Dockerfile
@@ -38,7 +38,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/7.3/stretch/apache/Dockerfile b/7.3/stretch/apache/Dockerfile
index 893f64856..952555776 100644
--- a/7.3/stretch/apache/Dockerfile
+++ b/7.3/stretch/apache/Dockerfile
@@ -37,18 +37,22 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- apache2 \
- && rm -rf /var/lib/apt/lists/*
-
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends apache2; \
+ rm -rf /var/lib/apt/lists/*; \
\
# generically convert lines like
# export APACHE_RUN_USER=www-data
@@ -64,7 +68,6 @@ RUN set -eux; \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
- /var/www/html \
; do \
rm -rvf "$dir"; \
mkdir -p "$dir"; \
@@ -73,6 +76,9 @@ RUN set -eux; \
chmod 777 "$dir"; \
done; \
\
+# delete the "index.html" that installing Apache drops in here
+ rm -rvf /var/www/html/*; \
+ \
# logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \
diff --git a/7.3/stretch/cli/Dockerfile b/7.3/stretch/cli/Dockerfile
index 9d5fefd68..f362d0b4a 100644
--- a/7.3/stretch/cli/Dockerfile
+++ b/7.3/stretch/cli/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/7.3/stretch/fpm/Dockerfile b/7.3/stretch/fpm/Dockerfile
index fb62558f3..1e9116a17 100644
--- a/7.3/stretch/fpm/Dockerfile
+++ b/7.3/stretch/fpm/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi
diff --git a/7.3/stretch/zts/Dockerfile b/7.3/stretch/zts/Dockerfile
index 290ae3e04..50afe9696 100644
--- a/7.3/stretch/zts/Dockerfile
+++ b/7.3/stretch/zts/Dockerfile
@@ -37,7 +37,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
ENV PHP_EXTRA_CONFIGURE_ARGS --enable-maintainer-zts --disable-cgi
diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template
index b603392fa..fa60736c2 100644
--- a/Dockerfile-alpine.template
+++ b/Dockerfile-alpine.template
@@ -32,7 +32,13 @@ RUN set -x \
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template
index 72108ab48..fd79e79dd 100644
--- a/Dockerfile-debian.template
+++ b/Dockerfile-debian.template
@@ -31,7 +31,13 @@ RUN apt-get update && apt-get install -y \
--no-install-recommends && rm -r /var/lib/apt/lists/*
ENV PHP_INI_DIR /usr/local/etc/php
-RUN mkdir -p $PHP_INI_DIR/conf.d
+RUN set -eux; \
+ mkdir -p "$PHP_INI_DIR/conf.d"; \
+# allow running as an arbitrary user (https://github.com/docker-library/php/issues/743)
+ [ ! -d /var/www/html ]; \
+ mkdir -p /var/www/html; \
+ chown www-data:www-data /var/www/html; \
+ chmod 777 /var/www/html
####
####
diff --git a/apache-Dockerfile-block-1 b/apache-Dockerfile-block-1
index e74f7a337..b853f9e1f 100644
--- a/apache-Dockerfile-block-1
+++ b/apache-Dockerfile-block-1
@@ -1,12 +1,10 @@
-RUN apt-get update \
- && apt-get install -y --no-install-recommends \
- apache2 \
- && rm -rf /var/lib/apt/lists/*
-
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
RUN set -eux; \
+ apt-get update; \
+ apt-get install -y --no-install-recommends apache2; \
+ rm -rf /var/lib/apt/lists/*; \
\
# generically convert lines like
# export APACHE_RUN_USER=www-data
@@ -22,7 +20,6 @@ RUN set -eux; \
"$APACHE_LOCK_DIR" \
"$APACHE_RUN_DIR" \
"$APACHE_LOG_DIR" \
- /var/www/html \
; do \
rm -rvf "$dir"; \
mkdir -p "$dir"; \
@@ -31,6 +28,9 @@ RUN set -eux; \
chmod 777 "$dir"; \
done; \
\
+# delete the "index.html" that installing Apache drops in here
+ rm -rvf /var/www/html/*; \
+ \
# logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log"; \