1.安装docker环境
yum install –y docker
2.启动docker
systemctl start docker
3.加入开机启动
systemctl enable docker.service
4.添加docker用户组
sudo groupadd docker
5.将当前用户加入docker用户组
sudo useradd docker kevin
6.下载nginx镜像,
docker pull nginx
7.运行dokcer nginx容器
docker run --name web -v /webapp/content:/usr/share/nginx/html:ro -d -p 80:80 -p 443:443 nginx
8.copy nginx自带配置文件
docker cp web:/etc/nginx/nginx.conf /etc/nginx.confdocker
9.停止当前web容器,并删除启动新的web容器
docker stop web
docker rm web
docker run --name web1 -v /webapp/content/:/usr/share/nginx/html:ro -v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro -d -p 80:80 -p 443:443 nginx
10.查看容器是否启动
docker ps
11.开放数据卷访问权限,防止css,js等403错误,问题连接http://ask.projectatomic.io/en/question/90/403-forbidden-when-accessing-volume-via-apache-in-docker-container/
chcon -Rt svirt_sandbox_file_t /webapp/content
12.进入Nginx容器交互式命令
docker exec -it web /bin/bash
网站目录/webapp/content
nginx配置目录/etc/nginx/nginx.conf