Each command in Dockerfile creates a new layer, so the best practice is to minimize them and to combine somehow, if it is possible.
The question is: can we manage this behavour in a similar way as transactions commits . With sql script, if you run DML
statements like:
insert into ...
update ...
delete
Each of them is commited immediately (in case autocommit is enable). You can wrap them and apply as a single transaction. With docker each command creates a new layer (also we can say, that each command is commited).
Instead of special hacks how to combine docker commands, I’d like to be able to control it. Something like:
FROM ...
BEGIN LAYER
RUN ...
COPY ...
EXPOSE ...
RUN ...
COMMIT LAYER
Probably it has been already requested and declined. If not, what do you think of it.