Dockfile自动创建discuz论坛和可道云
将discuz论坛的zip包解压之后用tar包压缩,这样ADD可以直接解压tar包。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | [root@localhost centos 6.9 _ssh_discuz]# pwd /opt/dockerfile/centos 6.9 _ssh_discuz [root@localhost centos 6.9 _ssh_discuz]# ls default .conf discuz.tar.gz Discuz_X 3.4 _SC_UTF 8 _ 0802 .zip dockerfile init.sh、 [root@localhost centos 6.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 centos 6.9 _ssh_discuz]# cat init.sh #!/bin/bash service nginx start service php-fpm start service mysqld start /usr/sbin/sshd -D [root@localhost centos 6.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:v 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
页面测试:
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
· Linux系列:如何调试 malloc 的底层源码
· JDK 24 发布,新特性解读!
· C# 中比较实用的关键字,基础高频面试题!
· .NET 10 Preview 2 增强了 Blazor 和.NET MAUI
· Ollama系列05:Ollama API 使用指南
· 为什么AI教师难以实现