因为需要挂着卷,先部署一个临时的容器:
docker run --name nginx -p 80:80 -d nginx:latest
然后拷贝文件夹到宿主机:
docker cp nginx:/etc/nginx/nginx.conf /publish/nginx/conf/nginx.conf docker cp nginx:/etc/nginx/conf.d /publish/nginx docker cp nginx:/usr/share/nginx/html /publish/nginx
停止临时的容器
docker rm -f nginx
# 重新创建容器并挂在主机文件
# -v /my_project/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf,将主机文件挂在到容器,
# 冒号前为主机路径,后为容器路径
docker run --name nginx -p 80:80 -v /my_project/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /my_project/docker/nginx/conf.d:/etc/nginx/conf.d -v /my_project/docker/nginx/html:/usr/share/nginx/html -v /my_project/docker/nginx/log:/var/log/nginx -d nginx:latest
标签:etc,部署,project,nginx,conf,docker,my From: https://www.cnblogs.com/liubaihui/p/17663052.html