# 1、创建文件夹 mkdir nginx-docker # 2、进入文件夹 cd nginx-docker vim nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } } 注意是在:nginx-docker 目录下建立, 和nginx.conf 同一层级
mkdir html Welcome to nginx! Success! The nginx server is working!
docker run --name my-nginx -d -p 80:80 \ -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf \ -v $(pwd)/html:/usr/share/nginx/html \ nginx 可以更换的