Dockfile自动创建discuz论坛和可道云

 

   讲discuz论坛的zip包解压之后用tar包压缩,这样ADD可以直接解压tar包。

[root@localhost centos6.9_ssh_discuz]# pwd
/opt/dockerfile/centos6.9_ssh_discuz
[root@localhost centos6.9_ssh_discuz]# ls
default.conf  discuz.tar.gz  Discuz_X3.4_SC_UTF8_0802.zip  dockerfile  init.sh、

[root@localhost centos6.9_ssh_discuz]# cat default.conf
server {
    listen       80 ;
    server_name  localhost;
    root         /code;
    index        index.php index.html index.htm;
    location / {
    }
    location ~ \.php$ {
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  /code$fastcgi_script_name;
         include        fastcgi_params;
     }
}
[root@localhost centos6.9_ssh_discuz]# cat init.sh
#!/bin/bash
service nginx start
service php-fpm start
service mysqld start
/usr/sbin/sshd -D
[root@localhost centos6.9_ssh_discuz]# cat 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  openssh-server nginx php-fpm  php-gd php-pecl-zendopcache php-mysqli mysql-server -y && \
service sshd start && \
echo "123456"|passwd --stdin root
ADD default.conf /etc/nginx/conf.d/default.conf
RUN mkdir /code
WORKDIR /code
ADD discuz.tar.gz .
RUN chmod -R 777 .  && \
mv upload/* . && \
service mysqld start && \
mysqladmin -uroot password '123456'
EXPOSE 22 80
ADD init.sh /init.sh
CMD ["/bin/bash","/init.sh"]

启动容器:
docker run -d -p 80:80 discuz:v1

 

 

打开网页测试:

 Dockfile自动创建discuz论坛和可道云_第1张图片

 

 

可道云:

[root@localhost centos6.9_ssh_kode]# pwd
/opt/dockerfile/centos6.9_ssh_kode
[root@localhost centos6.9_ssh_kode]# ls
dockerfile  init.sh  kode.tar.gz  nginx.conf


[root@localhost centos6.9_ssh_kode]# cat 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-mbstring php-fpm  php-gd    -y

ADD nginx.conf /etc/nginx/nginx.conf
RUN mkdir /code
WORKDIR /code
ADD kode.tar.gz .
RUN chown -R  apache.apache .
RUN chown -R  apache.apache /var/lib/nginx

EXPOSE 80
ADD init.sh /init.sh

CMD ["/bin/bash","/init.sh"]
[root@localhost centos6.9_ssh_kode]# cat init.sh
#!/bin/bash

service php-fpm start
nginx -g 'daemon off;'
[root@localhost centos6.9_ssh_kode]# cat nginx.conf
events {
      worker_connections  1024;
}
 http {
      include    mime.types;
      default_type application/octet-stream;
      sendfile      on;
      keepalive_timeout  65;
server {
    listen       80 ;
    server_name  localhost;
    root         /code;
    index        index.php index.html index.htm;
    location / {
    }

    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;
     }
}
}



[root@localhost centos6.9_ssh_kode]# docker build --network=host -t kode:v2 .
10b8fcc6a31760c8f3982ab539640aca48c7054f904ce5266bee69d5c1b1e680
[root@localhost centos6.9_ssh_kode]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                CREATED              STATUS                 PORTS                NAMES
10b8fcc6a317        kode:v2             "/bin/bash /init.sh"   5 seconds ago        Up 5 seconds                 0.0.0.0:80->80/tcp   unruffled_dewdney[root@localhost centos6.9_ssh_kode]# docker  run -d -p 80:80 kode:v2

  

 页面测试:

Dockfile自动创建discuz论坛和可道云_第2张图片

 

你可能感兴趣的:(Dockfile自动创建discuz论坛和可道云)