1、拉取nginx镜像
docker pull nginx
#注:默认为最新版本
2、 查看拉取的nginx镜像是否存在
docker images
3、 创建nginx挂载的目录
mkdir -p /docker/nginx/{conf,conf.d,html,logs}
4 、配置nginx挂载文件内容
在/docker/nginx/conf 目录下 编辑nginx.conf 文件
vim nginx.conf
user root;
worker_processes auto;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
sendfile on;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/