个人记录
拉取nginx
docker pull nginx:1.18
挂载文件 本地路径
mkdir -p /home/nginx/conf
mkdir -p /home/nginx/log
mkdir -p /home/nginx/html
生成容器
docker run --name nginx -p 80:80 -d nginx:1.18
将容器部分文件复制到宿主机
- 将容器nginx.conf文件复制到宿主机
- 将容器conf.d文件夹下内容复制到宿主机
- 将容器中的html文件夹复制到宿主机
docker cp nginx:/etc/nginx/nginx.conf /home/nginx/conf/nginx.conf
docker cp nginx:/etc/nginx/conf.d /home/nginx/conf/conf.d
docker cp nginx:/usr/share/nginx/html /home/nginx/
卸载Nignx
docker rm -f nginx
真实安装
docker run \
-p 80:80 \
--name nginx \
-v /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /home/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /home/nginx/log:/var/log/nginx \
-v /home/nginx/html:/usr/share/nginx/html \
-d nginx:1.18