Dockerfile构建kodexporer(七)

简介: dockerfile构建kodexporer.m1.手动构建kodexplorer容器1.1.运行一个centos6.9容器

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

image.pngimage.png

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
目录
相关文章
|
7月前
|
Linux Docker 容器
Docker中Dockerfile的构建过程
本章主要对Docker中自定义镜像的一种方式,docker进行简单的介绍。
102 1
Docker中Dockerfile的构建过程
|
3月前
|
Java 持续交付 Docker
Docker 项目如何使用 Dockerfile 构建镜像?
Docker 简介:讲述 Docker 的起源、它是如何革新现代软件开发的,以及它为开发者和运维团队带来的好处。重点强调 Docker 的轻量级特性和它在提高应用部署、扩展和隔离方面的优势。
|
4天前
|
JavaScript Java Docker
使用 Dockerfile 构建和定制 Docker 镜像
Dockerfile是构建Docker镜像的文本文件,包含一系列指令,如`FROM`, `WORKDIR`, `COPY`, `RUN`, `EXPOSE`和`CMD`。它用于自动化`docker build`命令来创建Image。使用Dockerfile可以基于官方镜像定制应用镜像,方便应用容器化和扩展。基本流程包括选择基础镜像、设置工作目录、安装依赖、暴露端口和定义启动命令。构建镜像使用`docker build`,运行容器用`docker run`。了解并熟练使用Dockerfile能提升容器化部署效率。
16 0
|
3月前
|
运维 Ubuntu Docker
【Docker】Dockerfile 构建文件
【1月更文挑战第26天】【Docker】Dockerfile 构建文件
|
3月前
|
网络协议 Java Shell
docker镜像构建之Dockerfile
docker镜像构建之Dockerfile
44 0
|
9月前
|
Java Shell Linux
41-Dockerfile-Dockerfile简介
41-Dockerfile-Dockerfile简介
|
11月前
|
Shell Linux 开发工具
一文简单了解并构建Dockerfile
一文简单了解并构建Dockerfile
169 0
|
Linux Docker 容器
Dockerfile 文件结构、docker镜像构建过程详细介绍
本文是博主学习docker 镜像制作的记录,希望对大家有所帮助
242 0
Dockerfile 文件结构、docker镜像构建过程详细介绍
|
Ubuntu 应用服务中间件 Shell
认识 Dockerfile 文件之镜像构建
了解 Dockerfile 指令语法并熟练掌握,如何编写 Dockerfile 文件来定制一个镜像。
225 1
认识 Dockerfile 文件之镜像构建