Here’s a neat tip when building a Dockerfile: make sure to use the --chown
parameter when COPY-ing files into the image instead of “wasting” another layer just for the RUN chown ..
operation.
Prerequisites
- Docker
Solution
So, instead of:
COPY . /appdir
RUN chown -R app:app /appdir
you can have something like this:
COPY --chown=app:app . /appdir
Conclusion
In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.