阅读量:0
1、找个位置:创建文件夹
# 1、创建文件夹 mkdir nginx-docker # 2、进入文件夹 cd nginx-docker
2、文件夹下:建nginx.conf文件
- vim 创建
vim nginx.conf
- 复制nginx内容
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; } } }
3、创建html目录
注意是在:nginx-docker 目录下建立, 和nginx.conf 同一层级
- 创建:html 文件夹
mkdir html
- html文件夹下:创建 index.html 文件
<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> </head> <body> <h1>Success! The nginx server is working!</h1> </body> </html>
4、部署docker
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
5、注意点
- html 挂载目录:/usr/share/nginx/html
可以更换的