When trying to start my roundcube mailserver on a docker container I get the apache error:

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 

Even if I declared all the envvars in the dockerfile like:

#FROM armv7/armhf-debian
FROM debian

RUN apt-get update -y && apt-get install sudo -y
RUN sudo apt-get install nano

# install exim,d ovecot, fetchmail, roundcoube
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y exim4 sudo wget ca-certificates
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y dovecot-imapd
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y fetchmail procmail
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 php5.* php5.*-mysql

RUN sudo mkdir -p /etc/php5/apache2/

# add www-data to sudoers
RUN echo "www-data ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# removing std. html site
RUN sudo rm /var/www/html/index.html

# downloading roundcube
RUN wget https://github.com/roundcube/roundcubemail/releases/download/1.2.3/roundcubemail-1.2.3-complete.tar.gz
RUN tar xvf roundcubemail-1.2.3-complete.tar.gz
RUN cp -rf roundcubemail-1.2.3/. /var/www/html/
RUN chown -R www-data:www-data /var/www/html/
RUN echo "MAIN_TLS_ENABLE = 1" >> /etc/exim4/exim4.conf.localmacros

# setting date.timezone
RUN echo 'date.timezone = "Europe/Berlin"' >> /etc/php5/apache2/php.ini

# enable fetchmail as daemon
RUN echo "START_DAEMON=yes" >> /etc/default/fetchmail

# let dovecot listen on ipv6
RUN echo "listen = *" >> /etc/dovecot/dovecot.conf

VOLUME ["/var/log/exim4"]

ADD ./scripts /scripts

# clean for smaller image
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# entrypoint
#ENTRYPOINT ["exim"]
ENTRYPOINT /bin/bash /scripts/init.sh
#CMD [/scripts/init.sh]

I'm starting it with an init.sh file as seen below

I also checked if the evvars and direcories exist in the docker container. The RUN_DIR is set and also /var/run/apache2 exists. Within is the apache2.pid set with an id.

When opening the localhost address the pure php code is shown..

  • What is in /etc/apache2/apache2.conf of the container. There seems to be an error on line 80. Apr 16, 2019 at 9:08
  • @ctrl-alt-delor line 80 in debian /etc/apache2/apache2.conf is DefaultRuntimeDir ${APACHE_RUN_DIR}. It seems the variables are not exported with ENV APACHE_XXX yyy.
    – Freddy
    Apr 16, 2019 at 9:24
  • @temp Why not use service apache2 start?
    – Freddy
    Apr 16, 2019 at 9:29
  • @Freddy How to export them? adding service apache2 start at least let's me reach the port. But the problem's still there.
    – temp
    Apr 16, 2019 at 9:53
  • @temp Does it work if you export them in your init.sh, e.g. export APACHE_RUN_DIR=/var/lock/apache2 (like in /etc/apache2/envvars)?
    – Freddy
    Apr 16, 2019 at 10:00

1 Answer 1

  • Remove apache variables from docker file
  • Replace init.sh:

    # define path to custom docker environment
    # write variables to DOCKER_ENVVARS
    cat << EOF > "$DOCKER_ENVVARS"
    export APACHE_RUN_USER=www-data
    export APACHE_RUN_GROUP=www-data
    export APACHE_LOG_DIR=/var/log/apache2
    export APACHE_LOCK_DIR=/var/lock/apache2
    export APACHE_PID_FILE=/var/run/apache2.pid
    export APACHE_RUN_DIR=/var/run/apache2
    # source environment variables to get APACHE_PID_FILE
    # only delete pidfile if APACHE_PID_FILE is defined
    if [ -n "$APACHE_PID_FILE" ]; then
       rm -f "$APACHE_PID_FILE"
    # start other services
    service exim4 start
    service dovecot start
    service fetchmail start
    # line copied from /etc/init.d/apache2
    ENV="env -i LANG=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    # use apache2ctl instead of /usr/sbin/apache2
  • I used your init and removed the stuff from my dockerfile (see edited question).. but still the same error. :/
    – temp
    Apr 16, 2019 at 11:45
  • @temp It works on my debian. The important change is to define APACHE_ENVVARS and to use apache2ctl. Apache should start in foreground if you run APACHE_ENVVARS=/etc/apache2/docker_envvars apache2ctl -DFOREGROUND in terminal as root.
    – Freddy
    Apr 16, 2019 at 11:59
  • Okay... Any idea what the problem in my case could be? Maybe something with the docker setup?
    – temp
    Apr 16, 2019 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.