Docker deployment web page refers to the configuration of nginx

recently deployed web pages with docker, but I encountered a problem as follows:
when normal deployment, that is, no docker is used, the configuration of the configuration file under nginx"s site-enabled is as follows

server {
    charset utf-8;
    listen 80;
    server_name windystreet.cn;
    
    location /static {
    alias /var/www/static;
    }
    location / {
    proxy_set_header Host $host;
    proxy_pass http://unix:/tmp/windystreet.cn.socket;

    }
}

when using docker deployment, it seems that for the online tutorials, I should need to change the configuration file, and only change the server_name, as follows

server {
    charset utf-8;
    listen 80;
    server_name localhost;
    
    location /static {
    alias /var/www/static;
    }
    location / {
    proxy_set_header Host $host;
    proxy_pass http://unix:/tmp/windystreet.cn.socket;

    }
}

but when I run

docker run -it -p 80:80 xxx(id) /bin/bash

when you open a web page, you cannot load a static file? How can I be an agent?


your static file directory is not mapped. Now you are using the directory in docker


run docker run-it-p 80:80-v / var/www/static:/var/www/static xxx (container id) / bin/bash

Menu