Could not reliably determine the server's fully qualified domain name ... How to solve it in Docker?

Viewed 130703

I am just starting in Docker and I was following that tutorial that shows basically these steps:

  1. Create a Dockerfile like this:

    From php:7.0-apache
    copy src/ /var/www/html
    EXPOSE 80
    
  2. Build the container from where I have my dockerfile:

    $ docker build -t mytest .
    
  3. After the image "mytest" is generated I run it with:

    $ docker run  -p 80 mytest
    

That is what I get as error:

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 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 [Sun Sep 17 16:25:12.340564 2017] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) PHP/7.0.23 configured -- resuming normal operations [Sun Sep 17 16:25:12.340666 2017] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

So, I don't know how to solve it. Any idea?

6 Answers

Problem:
While running docker file giving below error:

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


Solution:
goto root
goto etc file
then goto apache2
then nano apache2.conf file
and then below the line # The directory where shm and other runtime files will be stored. put a new line (Enter) and write:

ServerName localhost

Save the file and exit root and run the docker run command again, it will work.


Youtube video reference link for the same issue: Watch

I use to add

sed -i -e 's/Listen 80/Listen 80\nServerName localhost/' /etc/apache2/ports.conf

either to the Dockerfile or to the entrypoint file if used.

If you are using docker do this: add ServerName localhost to apache2.conf from the Dockerfile and then restart the server

RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf

RUN service apache2 restart

this should get rid of the warning.

you can also do this from the terminal

echo "ServerName localhost" >> /usr/local/etc/apache2/apache2.conf

and don't forget to restart your server

sudo systemctl restart apache2

The error should be gone after the server restart.

Related