简体   繁体   中英

Docker/nginx [windows10] - change page on linked folder and show changes directly in the browser

Question : How can I change the index.html file in docker/nginx and see the changed results in my browser? The index.html is on a private folder linked to the standard nginx folder.

What did I do : After installing docker and nginx via the official pages, I created a folder under /Users/me123/docker/webapp/html. In this folder I created an index.html file.

I linked this folder to the default nginx folder via the following command. I used both the RO and not-RO versions:

docker run --name nginx -p 80:80 -v //c/Users/me123/docker/webapp/html:/usr/share/nginx/html -d nginx

So, when editing the file (with eg Notepad++) I expected to see the updates. Alas, even in firefox with ctrl-F5 or control-refresh-icon. So, this is really not a caching problem. I visited the page via 192.nnn/index.html.

When I delete the index.html file, then I got an error. When I put the index.html file back I see the old index.html content.

I saw a post that this may be due to inode-synchronisation/updates. So a 'docker restart nginx' would be sufficient. Alas. Even the sequence 'docker stop nginx' and 'docker rm nginx-package-via-number' won't help.

When I add a new file to my local /Users/me123/docker/webapp/html folder, I immediately see the contents.

So, how can I change the index.html file and see the changed results in my browser?

I tried to add tags in my index.html to prohibit caching - alas.

The solution is by changing the nginx.conf file.

Use the following and the problem is solved:

sendfile        off;

By default it is set on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM