举个例子:

     mkdir  nginx

     cd nginx

     需要的文件如下

     nginx.conf  nginx配置文件模板

     cat index.php  php测试页面

<?php
phpinfo();
?>

 

     nginx.ini   supervisor的子配置文件

/usr/sbin/nginx 默认是后台运行,但supervisor 无法监控后台运行的进程,所以 -g 关闭后台运行

[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=True
[program:php-fpm]
command=/usr/sbin/php-fpm -F
autostart=True

 

     cat defualt.conf

location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

 cat Dockerfile

FROM 10.30.47.120/docker/centos
RUN yum -y install epel-release &&  yum -y install supervisor nginx php php-mysql php-fpm
COPY nginx.conf /etc/nginx/nginx.conf
COPY default.conf /etc/nginx/conf.d/default.conf
COPY nginx.ini /etc/supervisord.d/
COPY index.php /usr/share/nginx/html/
CMD ["supervisord","-n"]