Default Service Configs

How nginx, PHP, Redis and OpenSearch default configs are published from the image, and why rebuilding the image overwrites your edits to them.

How defaults are published

On every container start, nginx, PHP, and Redis each run rsync -ru in their startup script, publishing default config files from the image (/opt/<service>_conf/) to the matching project directory on the host. OpenSearch does the same from a different source, its configured prefix’s config/ directory, and also appends a separate opensearch.custom.yml file into opensearch.yml.

The -u (update) flag makes rsync skip any host file that is newer than its counterpart in the image. It compares modification times, not contents. The image’s copies are dated when the image is built, and your copies when rsync publishes them or when you last save them. In practice:

  • A container restart, or a rebuild Docker serves from its cache, changes nothing, since your copies are newer than the image’s.
  • When the image is actually rebuilt, for example after a version bump or a settings change that recompiles the service, the image’s copies become the newest. Every shipped file is then overwritten with the new defaults, including any you’ve edited.
  • An edit you make after that rebuild is kept until the next one.

OpenSearch is the exception. Its config files keep the dates they have in the upstream release archive, so they’re older than your copies and are only ever published once, into an empty directory. Later versions’ defaults never reach your project.

Add files, don’t edit shipped ones

Since a rebuild overwrites the shipped files, add your customizations as a new file rather than editing a shipped one. A few services already have a dedicated place for this:

Service Directory published Add custom settings here instead
nginx nginx/conf/ New .conf file in nginx/conf/conf.d/, included automatically
PHP php/conf/ New .ini file in php/conf/conf.d/, loaded automatically in alphabetical order
Redis redis/conf/ No dedicated extension point. An include line added to redis.conf is overwritten along with the rest of the file
OpenSearch opensearch/conf/ opensearch.custom.yml, appended into opensearch.yml automatically on every start

When there’s no dedicated extension point and you have to edit a shipped file directly, keep a copy of your changes, and reapply them whenever the service’s image is rebuilt.