dockerfile构建kodexporer.m
1.手动构建kodexplorer容器
1.1.运行一个centos6.9容器
[root@docker01 ~]# docker run -d -it -p 80:80 --name=centos69_kod centos:6.9
1.2.进入容器
[root@docker01 ~]# docker exec -it centos69_kod /bin/bash
1.3.配置yum仓库
[root@docker01 ~]# rm -rf /etc/yum.repos.d/* [root@docker01 ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo ;curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
1.4.安装nginx、php
[root@docker01 ~]# yum -y install nginx php-fpm php-cli php-gd php-mbstring unzip vim lrzsz
1.5.配置nginx
1.配置kodexporer站点文件 [root@docker01 ~]# cd /etc/nginx/conf.d/ [root@7a31e9aa8f44 conf.d]# rename .conf .off * [root@7a31e9aa8f44 conf.d]# vim kodexporer.conf #kodexporer server { listen 80; server_name kodexporer.com; location / { root /web/kodexporer; index index.php index.html; } location ~ \.php$ { root /web/kodexporer; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 2.重启nginx [root@7a31e9aa8f44 conf.d]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful root@7a31e9aa8f44 conf.d]# /etc/init.d/nginx start Starting nginx: [ OK ]
1.6.配置php
[root@7a31e9aa8f44 ~]# vim /etc/php-fpm.d/www.conf user = nginx group = nginx [root@7a31e9aa8f44 ~]# /etc/init.d/php-fpm start Starting php-fpm: [ OK ]
1.7.配置站点
用rz命令上传 [root@7a31e9aa8f44 kodexporer]# unzip kodexplorer_a5.zip [root@7a31e9aa8f44 kodexporer]# chown -R nginx:nginx .
1.8.访问
访问192.168.81.210,密码前面已经设置admin/admin
2.利用dockerfile自动构建kodexplorer
2.1.准备nginx配置文件
[root@docker01 centos69_kod]# docker cp centos69_kod:/etc/nginx/conf.d/kodexporer.conf .
2.2.编写init.sh脚本
[root@docker01 centos69_kod]# vim init.sh #!/bin/bash /etc/init.d/php-fpm start nginx -g 'daemon off;'
2.3.编写dockerfile
[root@docker01 centos69_kod]# vim dockerfile #kodexporer FROM centos:6.9 #配置yum源 RUN rm -rf /etc/yum.repos.d/* RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo ;curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo RUN yum -y install nginx php-fpm php-cli lrzsz vim unzip php-gd php-mbstring #配置kod站点配置文件 RUN cd /etc/nginx/conf.d/ && rename .conf .off * ADD kodexporer.conf /etc/nginx/conf.d/ RUN mkdir /web/kodexporer -p ADD kodexplorer_a5.zip /web/kodexporer RUN cd /web/kodexporer && unzip kodexplorer_a5.zip && chown -R nginx:nginx /web/ #配置PHP RUN sed -ri 's/apache/nginx/g' /etc/php-fpm.d/www.conf #启动环境 ADD init.sh /root/init.sh CMD ["/bin/bash","/root/init.sh"]
2.4.dockfile自建镜像
[root@docker01 centos69_kod]# docker build -t centos69_kod_df:v1
2.5.运行容器
[root@docker01 ~]# docker run -itd -p 85:80 centos69_kod_df:latest
2.6.访问
2.7.dockerfile目录
[root@docker01 centos69_kod]# tree . . ├── dockerfile ├── init.sh ├── kodexplorer_a5.zip └── kodexporer.conf 0 directories, 4 files
2.7.dockerfile目录
[root@docker01 centos69_kod]# tree . . ├── dockerfile ├── init.sh ├── kodexplorer_a5.zip └── kodexporer.conf 0 directories, 4 files