title: Cannot start apache automatically with docker
body: <p>I made a simple custom docker setup for php development. So far everything works as expected. The only thing that I cannot figure out is why apache2 does not start automatically.</p>
  
  <p>Here is my dockerfile:</p>
  
  <pre><code>FROM ubuntu:latest
  RUN apt-get update &amp;&amp; apt-get install -y apache2 php libapache2-mod-php php-mcrypt php-mysql php-cli php-curl php-xml php-intl php-mbstring git vim composer curl
  
  COPY . /var/www/example
  COPY vhost.conf /etc/apache2/sites-available/example.conf
  
  RUN a2ensite example
  RUN chown -R www-data:www-data /var/www/example/logs
  RUN service apache2 restart
  </code></pre>
  
  <p>And here is my docker-compose.yml:</p>
  
  <pre><code>version: '2'
  services:
    app:
      build:
        context: .
        dockerfile: Dockerfile
      image: myexampleapp
      ports:
          - 8080:80
      tty: true
  </code></pre>
  
  <p>And here is the output docker-compose up command:</p>
  
  <pre><code>me@mydell:~/workspace/mydockercompose$ docker-compose up -d --build
  Creating network "mydockercompose_default" with the default driver
  Building app
  Step 1/7 : FROM ubuntu:latest
   ---&gt; f975c5035748
  Step 2/7 : RUN apt-get update &amp;&amp; apt-get install -y apache2 php libapache2-mod-php php-mcrypt php-mysql php-cli php-curl php-xml php-intl php-mbstring git vim composer curl
   ---&gt; Using cache
   ---&gt; 148c3a9d928a
  Step 3/7 : COPY . /var/www/example
   ---&gt; 1fbc1dbacf1e
  Step 4/7 : COPY vhost.conf /etc/apache2/sites-available/example.conf
   ---&gt; 9c08947b09e9
  Step 5/7 : RUN a2ensite example
   ---&gt; Running in 1ef64defe747
  Enabling site example.
  To activate the new configuration, you need to run:
    service apache2 reload
  Removing intermediate container 1ef64defe747
   ---&gt; ca1c8e7e80fc
  Step 6/7 : RUN chown -R www-data:www-data /var/www/example/logs
   ---&gt; Running in 57b0214be7a0
  Removing intermediate container 57b0214be7a0
   ---&gt; b3b270a36bf4
  Step 7/7 : RUN service apache2 restart
   ---&gt; Running in 09d2b1d3bd91
   * Restarting Apache httpd web server 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
     ...done.
  Removing intermediate container 09d2b1d3bd91
   ---&gt; 19fa9a90f9de
  Successfully built 19fa9a90f9de
  Successfully tagged myexampleapp:latest
  Creating mydockercompose_app_1
  </code></pre>
  
  <p>It shows clearly that apache was restarted successfully. However it actually does not:</p>
  
  <pre><code>me@mydell:~/workspace/mydockercompose$ docker exec -i -t 20add8ad9895 service apache2 status
   * apache2 is not running
  </code></pre>
  
  <p>I am new to docker, so all suggestions (even if  they are not answering this specific question) to improve what I am doing so far are welcome.</p>
  
  <p>Thanks</p>