一、下载并上传phpwind安装包
wget http://192.168.12.201/docker_image/phpwind.tar.gz
wget http://192.168.12.201/docker_image/docker_centos6.9.tar.gz
docker load -i docker_centos6.9.tar.gz
二、创建dockerfile目录和文件
mkdir /data/dockerfile/phpwind/
第一版
FROM centos:6.9
RUN echo '192.168.12.201 mirrors.aliyun.com' >>/etc/hosts
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
RUN yum install nginx php-fpm -y
RUN yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-mcrypt -y
RUN yum install mysql-server -y
ADD phpwind.tar.gz /code
RUN chown -R nginx.nginx /code
ADD nginx.conf /etc/nginx/nginx.conf
ADD www.conf /etc/php-fpm.d/www.conf
ADD init.sh /init.sh
CMD ["/bin/bash","/init.sh"]
第二版:
vim dockerfile
FROM centos:6.9
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo && \
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo && \
yum install nginx php-fpm -y && \
yum install php-mysql php-gd libjpeg* php-ldap php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-mcrypt -y && \
yum install mysql-server -y && \
yum clean all
ADD phpwind.tar.gz /code
RUN chown -R nginx.nnginx /code
ADD nginx.conf /etc/nginx/nginx.conf
ADD www.conf /etc/php-fpm.d/www.conf
ADD init.sh /init.sh
EXPOSE 80
WORKDIR /code
ENTRYPOINT ["/bin/bash","/init.sh"]
vim init.sh
#!/bin/bash
/etc/init.d/mysqld start
/etc/init.d/nginx start
/etc/init.d/php-fpm start
tail -f /var/log/nginx/access.log
vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /code;
index index.php index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /code$fastcgi_script_name;
include fastcgi_params;
}
}
}
vim www.conf
user = nginx
group = nginx
三、启动dockerfile服务
docker build --network=host -t phpwind:v1 .
docker run -it -d phpwind:v1
四、浏览器访问地址测试:10.0.0.12
image.png image.png image.png image.png至此搭建完成。
网友评论