0

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

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>

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

On run: docker: Error response from daemon: create $(pwd)/src: "$(pwd)/src" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.
0

try typing docker ps to get all the processes running in containers. Then just type docker run -it container-id

It will start the apache server and show the address where it hosted it unless you want to add a different one in /etc/docker/daemon.json (https://docs.docker.com/engine/userguide/networking/default_network/custom-docker0/)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.