docker使用alpine镜像
-
-
安全:面向安全的轻量发行版;
-
简单:提供APK包管理工具,软件的搜索、安装、删除、升级都非常方便。
-
适合容器使用
docker pull alpine
docker run -it --name myalpine alpine:v1
#查看官方alpine镜像 docker search alpine #拉取镜像 docker image pull itsthenetework/nfs-server-alpine # 导入nginx镜像(推荐使用) docker load -i docker_nginx.tar.gz
2.
# 导入nginx镜像(推荐使用) docker load -i docker_nginx.tar.gz
docker run -it -p 80:80 alpine:latest / # sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories / # apk update
安装nginx
/ # apk add nginx / # mkdir /run/nginx / # nginx
return 404; #替换 root /html; index index.html;
提交成镜像
docker commit <alpineID> nginx_alpine:v1 docker run -d -p 81:80 nginx_alpine:v1 nginx -g 'daemon off;'
docker run -it -p 80:80 alpine:v1 / # sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories / # apk update / # apk add nginx / # mkdir /run/nginx / # nginx / # apk add php7 php7-fpm php7-opcache php7-curl php7-gd php7-mbstring php7-mysqli php7-json php7-iconv php7-exif php7-ldap php7-pdo php7-session php7-xml
安装 rc-service
apk add openrc --no-cache
启动nginx
service nginx start
#或者rc-service nginx start
遇到问题
WARNING: nginx is already starting
/# service nginx status * You are attempting to run an openrc service on a * system which openrc did not boot. * You may be inside a chroot or you may have used * another initialization system to boot this system. * In this situation, you will get unpredictable results! * If you really want to do this, issue the following command: * touch /run/openrc/softlevel /# touch /run/openrc/softlevel touch: /run/openrc/softlevel: No such file or directory /# mkdir -p /run/openrc /# touch /run/openrc/softlevel /# service nginx status * status: stopped /# service nginx start * WARNING: nginx is already starting /# /sbin/openrc * Caching service dependencies ... [ ok ] /# rc-service nginx start * /run/nginx: creating directory * /run/nginx: correcting owner * Starting nginx ... [ ok ]
启动php-fpm
vi /etc/php7/php-fpm.d/www.conf 所属主和所著组为nginx /# service php-fpm7 start * Checking /etc/php7/php-fpm.conf ... * /run/php-fpm7: creating directory * Starting PHP FastCGI Process Manager ... [ ok ]
加入启动服务
/# rc-update add nginx default
/# rc-update add php-fpm7 default
安装可道云
vim /etc/nginx/conf.d/default.conf server { listen 80 default_server; listen [::]:80 default_server; location / { root /html; index index.php index.html; include /etc/nginx/conf.d./*.conf; location ~ \.php$ { root /html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /html$fastcgi_script_name; include fastcgi_params; } } # You may need this to prevent return 404 recursion. location = /404.html { internal; } }
#检查格式 nginx -t
创建站点目录
mkdir /html cd /html wget http://static.kodcloud.com/update/download/kodexplorer4.40.zip chown -R nginx:nginx . #重启nginx service nginx restart service php-fpm7 restart
启动脚本文件
vim /init.sh service nginx start service nginx restart service php-fpm7 start service php-fpm7 restart tail -f /etc/hosts
docker commit optimistic_hermann alpine_kod:v1
验证镜像
docker run -d -p 80:80 alpine_kod:v1 /bin/sh /init.sh
登录网站10.0.0.12:80
查看
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!