docker-library/docs

/etc/apache2/envvars is not being loaded for php:7.2-apache

stiko opened this issue · 2 comments

stiko commented

To reproduce, simply run:

$docker run -d php:7.2-apache
$docker exec -ti <container_id> bash
$apache2 -t

Result:
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

If you source /etc/apache2/envvars then restart apache, the container stops. Starting it will repeat the cycle.

Any one has a solution to this?

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879571

You need to use apachectl or apache2ctl instead of calling apache2
directly. This is documented in /usr/share/doc/apache2/README.Debian.gz

$ docker run --rm -d --name php php:7.2-apache
$ docker exec -it php bash
root@6df9c23ae166:/var/www/html# apache2ctl -t
AH00558: apache2: Could not reliably determine the server's fully qualified domain

Syntax OK

Given that the issue is more of a usability question, it would be more suited for the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

The php:apache images actually use apache-foreground to load the apache envvars file; and not apache2 directly (or apache2ctl since that would require an init system in the container).

Next time, look at the Dockerfile of the image to see what command and entrypoint it runs by default:

# https://github.com/docker-library/php/blob/b599d7375c12ff69e4d11ea10c3dea56dd670eb9/7.2/stretch/apache/Dockerfile#L257-L263

ENTRYPOINT ["docker-php-entrypoint"]
##<autogenerated>##
COPY apache2-foreground /usr/local/bin/
WORKDIR /var/www/html

EXPOSE 80
CMD ["apache2-foreground"]

You can find links to all the Dockerfiles for all versions of official images on their respective Docker Hub descriptions (and in this repo).