导航
1、docker拉取nginx
docker pull nginx
2、创建windows的挂载目录及需要的文件
2.1 conf文件新建redis.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# 开启动态压缩
gzip on;
gzip_min_length 2k;
gzip_disable msie6;
gzip_types text/css text/javascript application/javascript image/png image/jpeg image/gif;
# 你需要代理的地址
server {
}
}
2.2 conf.d创建default.conf
这边数据不放也不影响
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
#autoindex on;
#try_files $uri /index/index/page.html;
#try_files $uri /index/map/page.html;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
2.3 www创建index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
2.4 web存放你的前端目录
例如dist
2.5 logs文件存放log文件
例如 access.log 和error.log
3、创建nginx容器
docker run --name nginx -p 80:80 --restart=always -v /D/docker/nginx/www:/usr/share/nginx/html -v /D/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /D/docker/nginx/logs:/var/log/nginx -v /D/docker/nginx/conf.d:/etc/nginx/conf.d
-v /D/docker/nginx/web/dist:/home/hometextile/web/dist -d nginx:latest