Docker file throwing error when i try to run it "AH00111: Config variable ${APACHE_RUN_DIR} is not defined"

Viewed 2674

I am trying my hands with Docker.

I am trying to install apche2 into ubuntu images.

FROM ubuntu

RUN echo "welcome to yellow pages"
RUN apt-get update
RUN apt-get install -y tzdata
RUN apt-get install -y apache2

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2

RUN echo 'Hello, docker' > /var/www/index.html

ENTRYPOINT ["/usr/sbin/apache2"]
CMD ["-D", "FOREGROUND"]

I found a reference online reference

I have added this line "RUN apt-get install -y tzdata" because it was asking for an option of tzdata and stopping image creation.

Now when I run my image I am getting the below error

[Thu Jan 07 09:43:57.213998 2021] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

I am new to docker and it's a bit of a task for me to understand it.

Could anyone help me out of this?

1 Answers

This seems to be Apache issue, not docker issue. Your conf seems to have errors. You have a parameter there called DefaultRuntimeDir which is pointing ad directory which does not exist in docker. Review your config file and ensure directories you specified in there exist in docker.

You can play within docker by simply:

docker build -t my_image_name .
docker run -it --rm --entrypoint /bin/bash my_image_name
# now you are in your docker container, you can check if your directories exist

Without knowing your config I would simply add one more RUN (I made this path up, you can change it to whatever you like)

ENV APACHE_RUN_DIR /var/lib/apache/runtime
RUN mkdir -p ${APACHE_RUN_DIR}

As a side note I would also combine all RUN into single like this:

RUN echo "welcome to yellow pages" \
    && apt-get update \
    && apt-get install -y tzdata apache2 \
    && rm -rf /var/lib/apt/lists/* \
    && mkdir -p /var/www \
    && echo 'Hello, docker' > /var/www/index.html

Related