1.拉取镜像
//拉取nginx镜像
docker pull nginx
2.创建本地挂载目录
//创建本地目录文件夹
mkdir /nginx/{conf,html,log}
3、在文件夹/nginx/conf下新建nginx.conf文件
//创建nginx.conf文件
touch nginx.conf
4.运行容器并把nginx容器的配置文件挂载到本地
docker run
-d //后台运行
--name nginx-test //名称
-p 80:80 //端口映射
-v /nginx/conf/nginx.conf:/etc/nginx/nginx.conf
-v /nginx/html:/usr/share/nginx/html
-v /nginx/log:/var/log/nginx
nginx
5、查看已启动的容器
docker ps
6.访问浏览器
ip:80
html路径:/usr/share/nginx/html
conf路径:/etc/nginx/conf.d/default.d
log路径:/var/log/nginx
孤独&烙印的博客_CSDN博客-springSecurity,spring-fox,vue领域博主