【发布时间】:2019-09-02 15:57:37
【问题描述】:
我正在使用 Docker 设置 nginx 服务器。如果我向 all-html 添加一个新文件/目录,该内容是否需要动态加载到 nginx(无需重新加载 nginx)?
只有在再次重建图像时(没有缓存),我才能加载新内容。有什么方法可以设置 nginx 配置以动态加载内容而不重建 docker 映像?
Dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y nginx
RUN rm /etc/nginx/nginx.conf
ADD nginx.conf /etc/nginx/
ADD web /usr/share/nginx/html/
ADD web /var/www/html/
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
EXPOSE 90
CMD service nginx start
nginx.conf
worker_processes 1;
events { worker_connections 1024; }
http {
include mime.types;
sendfile on;
server {
root /usr/share/nginx/html/;
index index.html;
server_name localhost;
listen 90;
location /all-html {
autoindex on;
}
}
}
ls web/
all-html icons index.html mime.types
ls web/all-html/
1.html ntf.zip 2.html
【问题讨论】:
标签: docker nginx nginx-config