title: php docker link apache docker
body: <p>I build 2 dockers, one docker with apache, one docker with php5, and I use docker-compose to start.</p>
  
  <p>apache2 Dockerfile in directoy apache2:</p>
  
  <pre><code>FROM debian:latest
  RUN apt-get update &amp;&amp; apt-get install -y apache2
  ADD test.php /var/www/html
  
  CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
  </code></pre>
  
  <p>and test.php:</p>
  
  <pre><code>&lt;?php
  phpinfo();
  ?&gt;
  </code></pre>
  
  <p>php5 Dorckerfile in directory php:</p>
  
  <pre><code>FROM debian:latest
  RUN apt-get update &amp;&amp; apt-get install -y php5
  </code></pre>
  
  <p>docker-compose.yml:</p>
  
  <pre><code>apache:
      build: ./apache2
      container_name: apache
      ports:
        - "80:80"
      links:
        - "php5"
  
  php5:
      build: ./php
      container_name: php
  </code></pre>
  
  <p>then I run:</p>
  
  <pre><code>docker-compose up
  </code></pre>
  
  <p>apache2 server start successfully. Then I access this server by <a href="http://server_ip" rel="noreferrer">http://server_ip</a>, then I get index of debian.But when I access <a href="http://server_ip/test.php" rel="noreferrer">http://server_ip/test.php</a>, just occur this:</p>
  
  <pre><code>&lt;?php
  phpinfo();
  ?&gt;
  </code></pre>
  
  <p>php just doesn't work.And I don't why.</p>