unable to run Apache/php from docker container

My requirement is using openface i need to train the dataset(images) and test each input image from webinterface (PHP) and all this activity should run from docker container.

I am able to achieve the above requirment on ubuntu machine. we are trying to install the complete setup(apache/php & openface) in docker. currently we are unable to invoke the html files from apache server using docker

  • no json module when running python script in docker container
  • docker-compose can't find services or containers in Docker for Mac
  • how does docker treat child process when we send stop to pid 1
  • getResource not work with jar running in docker
  • Moving a WordPress site to Docker, and eventually to a server
  • Dockerfile compile in local machine but fails in docker hub for automated build
  • The following the docker file used to import the project into docker and install apache/PHP. Please let me know if any changes need to be done in the dockerfile.

    FROM ubuntu:16.04
    
    RUN apt-get update && \
          apt-get -y install sudo
    
    RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
    
    ADD opencv-3.0.0 /
    
    ADD openface_setup.sh /
    
    RUN /openface_setup.sh
    
    ADD openface_work /
    
    
    RUN apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install \
    apache2 php7.0 libapache2-mod-php7.0 curl lynx-cur
    
    RUN a2enmod php7.0
    RUN a2enmod rewrite
    
    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 8080
    
    VOLUME /var/www/html # **my PHP/html files are located here. In the docker container the html/php files are not reflecting**
    
    ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
    
    CMD /usr/sbin/apache2ctl -D FOREGROUND
    

    Once the container is started i want the test.html(located in /var/www/html) to be running.

    FYI :

    1. command to created docker image

      sudo docker build -t myname/apache-test .

    2. command to start the docker container

      docker run -p 8080:80 -d <imageid>

  • docker: possible to create a single file with binaries and packages installed?
  • Passenger Still Runs in Production Despite Everything Seeming to Be Correct?
  • Docker /etc/apache2/sites-enabled/000-default.conf not updating
  • How to stop docker
  • How does docker interpret CMD?
  • Problems connecting pycharm to remote interpreter via docker
  • One Solution collect form web for “unable to run Apache/php from docker container”

    I’d suggest to use the official PHP image with a pre-installed Apache installation.

    Your project might look like this:

    .
    ├── Dockerfile
    └── src
        └── index.php
    

    while your Dockerfile consists of this:

    FROM php:7.1-apache
    # now RUN here your commands to install openface etc.
    

    and your index.php could look like this:

    <?php phpinfo();
    

    Then build the image:

    docker build -t myapache .
    docker run --rm -p 8080:80 -v $(pwd)/src:/var/www/html myapache
    

    http://localhost:8080 shows the php-info page.

    You can extend the image to your needs and it’s much simpler than your approach. Hope this might help.

    If you do not need to install anything else, you can directly use the php:7.1-apache image when creating a new container.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.