Answers: <p>You need to expose the container ports locally using either:</p>
  
  <ul>
  <li><code>docker run --rm -it -p 8080:80 myapp</code></li>
  <li>or a <code>docker-compose.yml</code> file:</li>
  </ul>
  
  <pre><code>services:
    myapp:
      image: myapp:tag
      ports:
      - 8080:80
  </code></pre>
  
  <p>Then, you'll be able to <code>curl localhost:8080</code>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-09-13T12:40:20.707Z
Answers: 2019-09-13T12:40:20.707Z
Answers: Hedi Nasr
Answers: <p>A side-note (sorry, I haven't got enough reputation to post direct comments yet):
  I see you are basing your image off of Ubuntu (<code>FROM ubuntu:bionic</code>) and then installing Apache... I would suggest using an image that's already tailored for this function, such as <a href="https://hub.docker.com/_/httpd" rel="nofollow noreferrer">the Apache HTTP Server</a>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-09-24T08:02:40.703Z
Answers: 2019-09-24T08:02:40.703Z
Answers: maze
Body: <p>I'm trying to deploy PHP files in Apache container using Dockerfile, Dockerfile on console shows successfully built and tagged but after running the container, i couldn't access the container IP or Container URL in local browser</p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM ubuntu:bionic
  RUN apt-get update
  RUN apt-get install -y software-properties-common &amp;&amp; \add-apt-repository ppa:ondrej/php &amp;&amp; apt-get update
  RUN apt-get -y upgrade &amp;&amp; DEBIAN_FRONTEND=noninteractive apt-get -y install \
  apache2 php7.0 php7.0-mysql libapache2-mod-php7.0
  RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/apache2/php.ini
  RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.0/apache2/php.ini
  
  ENV APACHE_RUN_USER www-data
  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
  ADD www /var/www/site
  ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
  ADD hosts /etc/hosts
  CMD /usr/sbin/apache2ctl -D FOREGROUND ```
  </code></pre>
  
Tags: <docker><docker-compose><dockerfile>
Title: Docker: PHP deployment in apache, couldn't acces container URL in local browser; shows blank page
UserDisplayName: Srikanth Peddireddy
ThreadText: # Docker: PHP deployment in apache, couldn't acces container URL in local browser; shows blank page
  
  (Asked by: username_0 on 2019-09-13)
  
  I'm trying to deploy PHP files in Apache container using Dockerfile, Dockerfile on console shows successfully built and tagged but after running the container, i couldn't access the container IP or Container URL in local browser
  
  **Dockerfile**
  
  ```
  FROM ubuntu:bionic
  RUN apt-get update
  RUN apt-get install -y software-properties-common && \add-apt-repository ppa:ondrej/php && apt-get update
  RUN apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install \
  apache2 php7.0 php7.0-mysql libapache2-mod-php7.0
  RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/apache2/php.ini
  RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.0/apache2/php.ini
  
  ENV APACHE_RUN_USER www-data
  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
  ADD www /var/www/site
  ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
  ADD hosts /etc/hosts
  CMD /usr/sbin/apache2ctl -D FOREGROUND ```
  
  ```
  
  **Tags:** docker, docker-compose, dockerfile
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-09-13. Score: 1
  
  You need to expose the container ports locally using either:
  
  * `docker run --rm -it -p 8080:80 myapp`
  * or a `docker-compose.yml` file:
  
  ```
  services:
    myapp:
      image: myapp:tag
      ports:
      - 8080:80
  
  ```
  
  Then, you'll be able to `curl localhost:8080`.
  
  
  ---
  
  ### Answer by username_2 on 2019-09-24. Score: 0
  
  A side-note (sorry, I haven't got enough reputation to post direct comments yet):
  I see you are basing your image off of Ubuntu (`FROM ubuntu:bionic`) and then installing Apache... I would suggest using an image that's already tailored for this function, such as [the Apache HTTP Server](https://hub.docker.com/_/httpd).
  
  
  ---
  
  