docker构建一个简易镜像

一 下载centos镜像

docker pull centos

二 启动镜像

[root@Centos-node3 ~]# docker run -it --name my_ng centos bash

三 下载yum源安装nginx,php,supervisor

[root@7113a79455d1 yum.repos.d]# yum -y install nginx
[root@7113a79455d1 yum.repos.d]# yum install php-fpm -y
[root@7113a79455d1 yum.repos.d]# yum -y install supervisor -y

四 修改Ngix配置文件

vi /etc/nginx/nginx.conf
    location ~ \.php$ {
            fastcgi_pass  127.0.0.1:9000;
           # fastcgi_pass  unix:/var/run/php-fcgi.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            include fastcgi_params;
            }
#编写index.php文件
[root@64d279ca2405 /]# vi /usr/share/nginx/html/index.php 

  <?php
  phpinfo();
  ?>

 

四 编写supervisor配置文件

[root@64d279ca2405 /]# vi /etc/supervisord.d/php_nginx.ini
[supervisord]
nodaemon=true
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
[program:phpfpm]
command=/usr/sbin/php-fpm -F -c /etc/php.ini
autostart = true
startsecs = 3
autorestart = true
startretries = 3
user = root
redirect_stderr = false
stdout_logfile_maxbytes = 50MB
stdout_logfile_backups = 20
[root@7113a79455d1 supervisord.d]# supervisord 启动

五 新开窗口打包镜像

[root@Centos-node3 ~]# docker commit -m "nginx 1.1 php 5.4" my_ng yanshicheng/testnginx:v1
sha256:4b9cc5c96908391b8d52c9938a50fedcf6f286f8be3ee1f2cc8d48534802e6d8

六 启动测试

docker run -it -p 80:80 --name ng yanshicheng/testnginx:v1 supervisord

 

转载于:https://www.cnblogs.com/yanshicheng/p/9465777.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值