Docker:部署Nginx - 详解


一、搜索镜像

docker search docker-0.unsee.tech/mysql:1.14.2

二、拉取镜像

docker pull mysql:1.14.2

三、创建本地挂载目录

mkdir -p /root/mysql/{conf,html,log}

四、拷贝配置文件

启动临时nginx

docker run -d --name nginx_test nginx

拷贝需要挂载的文件

docker cp nginx_test:/etc/nginx/conf.d /root/nginx/conf
docker cp nginx_test:/etc/nginx/nginx.conf /root/nginx/conf/nginx.conf
docker cp nginx_test:/usr/share/nginx/html/index.html /root/nginx/html/index.html

删除临时nginx

docker rm -f nginx_test

五、启动容器

docker run -d --name nginx -p 80:80\
--restart=unless-stopped \
-v /root/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /root/nginx/html/index.html:/usr/share/nginx/html/index.html \
-v /root/nginx/log:/var/log/nginx \
--network 网络名称 \
nginx:1.14.2
posted @ 2025-08-26 10:55  wzzkaifa  阅读(10)  评论(0)    收藏  举报