【Docker】02-Docker安装Nginx
Docker安装Linux
Nginx安装
1 | # 拉取nginx镜像 |
Nginx安装步骤
拉取镜像
1
docker pull nginx
创建挂载目录
1
2
3mkdir -p /usr/local/docker/nginx/conf
mkdir -p /usr/local/docker/nginx/log
mkdir -p /usr/local/docker/nginx/html容器中的文件复制到宿主机
1
2
3docker run --name nginx -p 80:80 -d nginx
docker cp nginx:/etc/nginx/nginx.conf /usr/local/docker/nginx/conf/nginx.conf
docker cp nginx:/etc/nginx/conf.d /usr/local/docker/nginx/conf/conf.d关闭并删除容器
1
2
3docker ps -a
docker stop nginx
docker rm nginx挂载方式启动nginx
1
2
3
4
5
6docker run -p 80:80 --name nginx \
-v /usr/local/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /usr/local/docker/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /usr/local/docker/nginx/log:/var/log/nginx \
-v /usr/local/docker/nginx/html:/usr/share/nginx/html \
-d nginx
-------------本文结束感谢您的阅读-------------
相关文章