docker 离线安装openresty

159 阅读1分钟

openresty下载链接
pan.baidu.com/s/1hYcED9y6… 提取码: mib6

1、将文件上传到服务器

2、加载镜像文件

docker load < openresty.tar

3、运行临时容器

docker run -itd --name openresty -p 80:80  openresty/openresty

4、在宿主机内创建相应目录

mkdir -p /docker/openresty/nginx/conf
mkdir -p /docker/openresty/nginx/conf.d
mkdir -p /docker/openresty/nginx/html
mkdir -p /docker/openresty/nginx/logs
mkdir -p /docker/openresty/nginx/lua

5、将容器内必要的文件拷贝到宿主机上

docker cp openresty:/usr/local/openresty/nginx/conf/nginx.conf /docker/openresty/nginx/conf/nginx.conf
docker cp openresty:/etc/nginx/conf.d/default.conf /docker/openresty/nginx/conf.d/default.conf
docker cp openresty:/usr/local/openresty/nginx/html/index.html /docker/openresty/nginx/html/index.html

6、删除临时容器

docker stop openresty
docker rm openresty

7、创建正式容器

docker run -it --name openresty -p 80:80 \
--privileged=true \
--restart=always \
-v /docker/openresty/nginx/conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf \
-v /docker/openresty/nginx/conf.d:/etc/nginx/conf.d \
-v /docker/openresty/nginx/html:/usr/local/openresty/nginx/html \
-v /docker/openresty/nginx/logs:/usr/local/openresty/nginx/logs \
-v /docker/openresty/nginx/lua:/usr/local/openresty/nginx/lua \
-d openresty/openresty