Member-only story

‘An accident caused by Docker container mounting’

Beck Moulton
4 min readOct 28, 2024

--

Will Script House Set as“ Star symbol
Received article updates as soon as possible

Source | Java Technology North (ID: javanorth)

background

Deploying nginx using Docker and configuring file mounting with the following parameters:

  • -v /deploy/nginx/conf.d/doc.crt:/etc/nginx/conf.d/doc.crt
  • -v /deploy/nginx/conf.d/doc.key:/etc/nginx/conf.d/doc.key
  • -v /deploy/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf

Due to technical reasons, it is necessary to add a location in the future*.htmlDisable cache, configure as follows

if ($request_filename ~* .*\\.(htm|html)$) {
add_header Cache-Control "no-store";
}

So I directly modified it on the host computer/deploy/nginx/conf.d/default.confFile.

Then run itdocker exec -it pc-nginx nginx -s reloadMake the configuration effective.

But the actual test results did not take effect

I thought the configuration was wrong, so I spent a long time and changed several methods, but none of them worked.

Until I entered the container and checked the files inside, I found that the files…

--

--

Beck Moulton
Beck Moulton

Written by Beck Moulton

Focus on the back-end field, do actual combat technology sharing Buy me a Coffee if You Appreciate My Hard Work https://www.buymeacoffee.com/BeckMoulton

No responses yet