1.拉取最新images
docker pull openresty/openresty:latest
2.创建简单容器
docker run -itd --restart=unless-stopped \
--name openresty \
-p 80:80 \
openresty/openresty:latest
3.创建成功后将重要配置文件从容器中复制出来,方便后续挂载。/data/docker/openresty文件夹自己创建好
docker cp bcbca2ce1641:/etc/nginx/conf.d /data/docker/openresty/conf.d
docker cp bcbca2ce1641:/usr/local/openresty/nginx/conf /data/docker/openresty/nginx.conf
docker cp bcbca2ce1641:/usr/local/openresty/nginx/logs /data/docker/openresty/logs
docker cp bcbca2ce1641:/usr/local/openresty/nginx/html /data/docker/openresty/html
4.销毁刚才创建的简单容器
docker ps
docker stop 容器id
docker rm 容器id
5.创建复杂容器**个人建议把创建命令编辑成.sh的脚本文件
docker run -itd --restart=unless-stopped \
--name openresty \
-p 80:80 \
-v /data/docker/openresty/conf.d:/etc/nginx/conf.d \
-v /data/docker/openresty/nginx.conf:/usr/local/openresty/nginx/conf/ \
-v /data/docker/openresty/logs:/usr/local/openresty/nginx/logs \
-v /data/docker/openresty/html:/usr/local/openresty/nginx/html \
-v /data/docker/openresty/cert:/usr/local/openresty/nginx/cert \
-v /data/docker/openresty/run:/var/run/openresty \
-v /data/docker/openresty/nginx/lua:/usr/local/openresty/nginx/lua \
openresty/openresty:latest