docker安装nginx并挂载
2、简单启动一个nginx服务(仅用来复制配置文件,复制完即删除此容器)3、复制nginx配置文件到宿主机。拉取docker中nginx镜像。1、本地创建nginx挂载路径。5、创建nginx网络。
·
拉取docker中nginx镜像
docker pull nginx
1、本地创建nginx挂载路径
mkdir /usr/local/docker/nginx/conf
mkdir /usr/local/docker/nginx/conf/conf.d
mkdir /usr/local/docker/nginx/html
mkdir /usr/local/docker/nginx/conf
2、简单启动一个nginx服务(仅用来复制配置文件,复制完即删除此容器)
docker run --name nginx_test -d -p 80:80 nginx
3、复制nginx配置文件到宿主机
docker cp nginx_test:/etc/nginx/conf.d /usr/local/docker/nginx/conf/conf.d/ docker cp nginx_test:/etc/nginx/nginx.conf usr/local/docker/nginx/conf/ docker cp nginx_test:/usr/share/nginx/html/ /usr/local/docker/nginx/html/
4、移除容器
docker rm -f nginx_test
5、创建nginx网络
docker network create nginx_network
docker run --name my_nginx -p 80:80 -v /usr/local/docker/nginx/conf/conf.d/default.conf:/etc/nginx/conf.d/default.conf -v /usr/local/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/docker/nginx/html/:/usr/share/nginx/html/ -v /usr/local/docker/nginx/logs/:/var/log/nginx/ --privileged=true -d --restart=always nginx
更多推荐
已为社区贡献1条内容
所有评论(0)