Interview Prep/Docker/Image design and Dockerfile decisions

Should you run `chmod`/`chown` in a separate `RUN` after `COPY`?

IntermediateScenarioImage design and Dockerfile decisions
Answer

Situation read → A separate RUN chown -R duplicates all copied files into a new layer, doubling size.

What I'd do →

COPY --chown=app:app --chmod=0755 entrypoint.sh /usr/local/bin/
COPY --chown=app:app . /app

Why → The metadata is set at copy time, with no duplicated layer.

Interview tip → --chmod requires BuildKit; it is the default builder since Docker 23.

All Docker questions Roadmap: Docker & containers

More on Image design and Dockerfile decisions