How to disable Nginx caching when running Nginx us

2019-05-05 08:52发布

I use the official nginx docker image (https://registry.hub.docker.com/_/nginx/). When I modify the Index.html I don't see my change. Setting sendfile off in nginx.conf didn't help.

I only see the change if i rebuild my image.

Here is my Dockerfile:

FROM nginx
COPY . /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/default.conf /etc/nginx/conf.d/default.conf

And that's the commands I use to build and run it:

docker build -t some-nginx .
docker run --name app1 -p 80:80 -v $(pwd):/user/share/nginx/html -d some-nginx

Thank you

2条回答
Rolldiameter
2楼-- · 2019-05-05 09:18

Just modify sendfile off in nginx.conf file can be work.

查看更多
等我变得足够好
3楼-- · 2019-05-05 09:40

It's not caching. Once a file is copied into a container image (using the COPY instruction), modifying it from the host will have no effect - it's a different file.

You've attempted to overwrite the file by bind-mounting a volume from the host using the -v argument to docker run. This will work - you will now be using the same file on host and container, except you made a typo - it should be /usr not /user.

查看更多
登录 后发表回答