title: Access a docker containers own localhost inside that container -- php apache
body: <p>I am trying to access the <code>http://localhost/</code> or <code>http://127.0.0.1</code> from <em>inside</em> the docker container itself. I can ping <code>localhost</code> when I am inside the running container:</p>
  
  <pre><code>$ sudo docker exec -i -t 045ff7f4755b /bin/bash
  $ ping 127.0.0.1
  PING 127.0.0.1 (127.0.0.1): 56 data bytes
  64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.108 ms
  </code></pre>
  
  <p>But, I get an error when I try</p>
  
  <pre><code>$ curl 127.0.0.1/api.php
  curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
  </code></pre>
  
  <p>Here is my dockerfile:</p>
  
  <pre><code>FROM php:7.1.0-apache
  RUN pecl install xdebug-2.5.0 \
      &amp;&amp; docker-php-ext-enable xdebug
  
  RUN mkdir /opt/framework
  COPY . /opt/framework
  COPY . /var/www/html/
  
  WORKDIR /opt/framework
  ENTRYPOINT ["docker-php-entrypoint"]
  </code></pre>
  
  <p>The endgame here, is to be able to run <a href="http://codeception.com" rel="nofollow noreferrer">codeception</a> (an acceptance tester) inside that container and for everything to be contained inside that container. I am also open to the idea that I may be approaching this entirely wrong. I am new to docker, and am not sure the best way to get my desired result.</p>