docker-nginx安装
docker下安装nginx
- 下载镜像
1
docker pull nginx
- 创建挂载卷
1
2
3mkdir -p /data/nginx/conf
mkdir -p /data/nginx/log
mkdir -p /data/nginx/html - 启动临时nginx容器
1
2
3
4
5
6docker run --name nginx-temp -p 80:80 -d nginx
#停止删除
docker stop nginx-temp
docker rm nginx-temp
#查看
docker ps -a - 复制docker容器中的配置文件到宿主机上
1
2
3docker cp nginx-temp:/etc/nginx/nginx.conf /data/nginx/conf/nginx.conf
docker cp nginx-temp:/etc/nginx/conf.d /data/nginx/conf/conf.d
docker cp nginx-temp:/usr/share/nginx/html /data/nginx/ - 启动nginx容器
1
2
3
4
5
6
7
8
9docker run \
-p 80:80 \
--name nginx \
--restart=always \
-v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /data/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /data/nginx/log:/var/log/nginx \
-v /data/nginx/html:/usr/share/nginx/html \
-d nginx:latest - 修改容器启动配置
1
2# 配置nginx自动启动
docker update --restart=always nginx - 查看nginx 启动命令
1
runlike -p nginx
引用文献
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Code Wolf!
评论

