01 · Before and afterThe pattern
# before: every user in the container can rewrite scripts that run on start
COPY --from=src /plugins/x /opt/plugins/x
RUN chmod -R 0777 /opt/plugins/x && /opt/plugins/x/install.sh
# after: owned by root, readable and executable by all, writable by root only
COPY --chown=root:root --from=src /plugins/x /opt/plugins/x
RUN chmod -R 0755 /opt/plugins/x && /opt/plugins/x/install.sh02 · Run it on your appThe check
Does any script that your container runs at start-up live in a folder that a non-root user can write to?
If the honest answer is no or not sure, this is worth a look before it reaches production.