Public Repository

Last pushed: 2 years ago
Short Description
nginx with php-fpm for php application
Full Description


Dockerfile let you spin nginx powered php5-fpm container.

Enabled extensions:

  • curl
  • mcrypt
  • mysql
  • mongo 1.4.5 (compatible with mongodb 2.6)
  • gd


Run it:

docker run -d -P maddog/nginx_php

Or to set application root, simply mount your host directory where application is present

docker run -d -v /my/app/root:/data/http -P maddog/nginx_php

Or to use custom nginx conf, mount directory containing nginx.conf file

docker run -d -v /my/app_nginx_conf/:/etc/nginx/sites-enabled  -P sahilsk/php5fpm

NOTE: Do change your root directory accordingly.

If logs are needed, mount host log directory as well

docker run -d -v /my/app/root:/data/http -v /var/log/app:/log -P maddog/nginx_php


FROM ubuntu:trusty

RUN apt-get update
RUN apt-get install -y squid-deb-proxy-client

RUN apt-get install -y htop vim supervisor bash-completion cron bash rsyslog \
    nginx php5-fpm php5-curl php5-mcrypt php5-mysql php5-mongo php5-gd

# correcting bashrc for bash-completion
RUN printf "\n\nif [ -f /etc/bash_completion ] && ! shopt -oq posix; then\n\t. /etc/bash_completion\nfi" >> /root/.bashrc

RUN ( mkdir -p /var/log/supervisor ; mkdir -p /log/ ; mkdir -p /data/http ; exit 0 )
RUN chown www-data:www-data /data/http

# Adding default supervisor file to container
ADD files/supervisor_conf.d/ /etc/supervisor/conf.d/

# Adding rsyslogs for cronjob
ADD files/cron-rsyslog.conf /etc/rsyslog.d/60-cron.conf

RUN sed -i -- 's/;daemonize = yes/daemonize = no/g' /etc/php5/fpm/php-fpm.conf
RUN echo "daemon off;" >> /etc/nginx/nginx.conf

RUN apt-get clean

ADD files/index.php /data/http/index.php

ADD files/nginx_default /etc/nginx/sites-available/default

RUN apt-get clean 
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

#Add volumes
VOLUME /data/http 
VOLUME /etc/nginx/sites-enabled

EXPOSE 80 443

# For running supervisor container at starting of docker container
CMD ( /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf )

Docker Pull Command