Docker:部署Nginx
目录
- 一、搜索镜像
- 二、拉取镜像
- 三、创建本地挂载目录
- 四、拷贝配置文件
- 五、启动容器
一、搜索镜像
docker search docker-0.unsee.tech/mysql:1.14.2
二、拉取镜像
docker pull mysql:1.14.2
三、创建本地挂载目录
mkdir -p /root/mysql/{conf,html,log}
四、拷贝配置文件
启动临时nginx
docker run -d --name nginx_test nginx
拷贝需要挂载的文件
docker cp nginx_test:/etc/nginx/conf.d /root/nginx/conf
docker cp nginx_test:/etc/nginx/nginx.conf /root/nginx/conf/nginx.conf
docker cp nginx_test:/usr/share/nginx/html/index.html /root/nginx/html/index.html
删除临时nginx
docker rm -f nginx_test
五、启动容器
docker run -d --name nginx -p 80:80\
-v /root/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /root/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /root/nginx/html/index.html:/usr/share/nginx/html/index.html \
-v /root/nginx/log:/var/log/nginx \
-- network 网络名称 \
nginx:1.14.2