Docker 컨테이너에서 Roundcube 메일 서버를 시작하려고 하면 Apache 오류가 발생합니다.
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
다음과 같이 dockerfile에 모든 환경 변수를 선언하더라도:
#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
#add
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]
아래와 같이 init.sh 파일을 사용하여 시작합니다.
또한 evvars 및 direcories가 docker 컨테이너에 있는지 확인했습니다. RUN_DIR이 설정되고 /var/run/apache2도 존재합니다. 그중에는 id가 있는 apache2.pid 설정이 있습니다.
localhost 주소를 열면 순수 PHP 코드가 표시됩니다.
답변1
- Docker 파일에서 Apache 변수 제거
바꾸다
init.sh
:#!/bin/bash # define path to custom docker environment DOCKER_ENVVARS=/etc/apache2/docker_envvars # 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 EOF # source environment variables to get APACHE_PID_FILE . "$DOCKER_ENVVARS" # only delete pidfile if APACHE_PID_FILE is defined if [ -n "$APACHE_PID_FILE" ]; then rm -f "$APACHE_PID_FILE" fi # 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 $ENV APACHE_ENVVARS="$DOCKER_ENVVARS" apache2ctl -DFOREGROUND