1.第一步 先拉取镜像
docker pull nginx:latest
2. nginx 容器内部一般地址配置如下:
日志位置:/var/log/nginx/ 配置文件位置:/etc/nginx/ 项目位置:/usr/share/nginx/html
我们对应映射路径到windows10的目录地址如下:
3.创建配置文件:
a.在conf中添加nginx.conf 内容如下:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '"$remote_addr" "$http_host" "[$time_local]" "$request" "$status" "$body_bytes_sent" '
'"$bytes_sent" "$gzip_ratio" "$http_referer" "$http_user_agent" "$http_x_forwarded_for" '
'"$upstream_addr" "$upstream_response_time" "$request_time" "$request_body" "$http_authorization" ';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
b. 在conf.d目录中创建文件default.conf和server9001.conf 在a步骤中的include /etc/nginx/conf.d/*.conf; 则会读取conf.d中配置的服