Docker Community Forums

Share and learn in the Docker community.

Can't reach a local website through apache in a docker container (windows & docker toolbox)

docker

(Jiboulex) #1

I built a Docker image with apache2 and a little configuration in order to run a local web server on windows.

Here is the Dockerfile :

FROM php:5.6.15-apache

RUN apt-get update && apt-get install -y \
apt-utils vim git php5-mysql php5-memcache php5-memcached php5-intl \
sendmail aptitude wget
RUN apt-get install libapache2-mod-php5 -y -o Dpkg::Options::="--force-confdef"
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install pdo pdo_mysql
RUN apt-get install libcurl4-gnutls-dev -y
RUN docker-php-ext-install curl
RUN apt-get update && apt-get install -y zlib1g-dev libicu-dev g++
RUN docker-php-ext-configure intl
RUN docker-php-ext-install intl

RUN a2enmod rewrite

ENV APACHE_RUN_USER test
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid

EXPOSE 80

COPY php.ini /usr/local/etc/php/php.ini

COPY apache-config.conf /etc/apache2/sites-enabled/000-default.conf

In apache-config.conf, I just have a little virtual host :

<VirtualHost *:80>
  ServerName test.loc
  DocumentRoot /var/www/html/test

  <Directory /var/www/html/test/>
      Allow from all
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

In my /c/Users/public/sites/test folder, I just have an index.php file with the following code in it :

<?php
phpinfo();

I built my image with this command in Docker Quickstart Terminal

docker build -t php56 .

Then I built my container :

docker run --name=php56_container -t --rm -v "//c/Users/Public/sites:/var/www/html" -p 80:80 -p 8080:8080 php56

The container is well created but I get the following 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
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
[Mon Dec 21 14:18:24.968215 2015] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.10 (Debian) configured -- resuming normal operations
[Mon Dec 21 14:18:24.968982 2015] [core:notice] [pid 1] AH00094: Command line: '

My problem is that I can’t access my test website and I don’t know why.

I tried to add the “ServerName 172.17.0.2” directive in /etc/apache2/apache2.conf, but when I restart apache2 service, it stops my container from running.

I tried to inspect my container to see its ip, but sometimes it doesn’t have one sometimes it’s 172.17.0.2

I tried the following adresses in my browser but I can’t reach anything :

http://test.loc

172.17.0.2:80

0.0.0.0:80

Does someone knows how to run a webserver with Docker on windows and reaching a site with his Servername ? (test.loc)