拉取镜像
docker pull nginx
一般启动
docker run -d -p 80:80 --name nginx nginx
挂载文件
创建本地目录
mkdir /usr/local/nginx
mkdir /usr/local/nginx/conf
mkdir /usr/local/nginx/conf.d
mkdir /usr/local/nginx/html
mkdir /usr/local/nginx/logs
创建nginx.conf、default.conf文件
从启动的镜像中获取
cd /etc/nginx/
more nginx.conf (copy)
cd /etc/nginx/conf.d
more default.conf (copy)
启动
docker run -d -p 80:80 --name nginx -v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /usr/local/nginx/conf.d:/etc/nginx/conf.d -v /usr/local/nginx/logs:/var/log/nginx -v /usr/local/nginx/html:/usr/share/nginx/html nginx