首页 > 解决方案 > apache2:无法可靠地确定服务器的完全限定域名,使用 172.17.0.2。

问题描述

我正在尝试在 docker 文件上的 ubuntu18.04 上配置 apache2。

我收到以下错误:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message

我知道这是一个警告,但是当我以交互方式运行图像时。我收到此消息,除此之外没有什么。我无法使用图像终端。

这里的问题 apache 没有找到“ServerName”。我试图在我的 docker 文件中覆盖它(目的只是拥有一台带有 apache 的 ubuntu 机器)

FROM ubuntu:18.04

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
ENV APACHE_RUN_DIR /var/run/apache2
RUN mkdir -p ${APACHE_RUN_DIR}
ENV APACHE_PID_FILE /var/run/apache2/apache2.pid
RUN touch /etc/apache2/sites-available/yellowpages.conf
RUN echo '<VirtualHost *:80> \n\
    ServerName myserver.mydomain.com \n\
    ServerAdmin webmaster@localhost \n\
    DocumentRoot /var/www/html \n\
    ErrorLog ${APACHE_LOG_DIR}/error.log \n\
    CustomLog ${APACHE_LOG_DIR}/access.log combined \n\
    </VirtualHost> \n'\
> /etc/apache2/sites-available/yellowpages.conf


RUN cat /etc/apache2/sites-available/yellowpages.conf

RUN a2ensite yellowpages.conf
RUN a2dissite 000-default.conf
RUN echo 'Hello, docker' > /var/www/index.html

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

谁能帮我绕过这个 apache2 错误?

标签: dockerapachedockerfile

解决方案


推荐阅读