I have noticed that many Dockerfiles try to minimize the number of instructions by several UNIX commands in a single RUN instruction. So i
In addition to the space savings, it's also about correctness
Consider your first dockerfile (a common mistake when working with debian-like systems which utilize apt):
FROM ubuntu
MAINTAINER demousr@example.com
RUN apt-get update
RUN apt-get install –y nginx
CMD ["echo", "Image created"]
If two or more images follow this pattern, a cache hit could cause the image to be unbuildable due to cached metadata
RUN apt-get update linedocker build will reuse that cached layer (since the dockerfile and base image are identical) up to the RUN apt-get updateRUN apt-get install line runs, it will use the cached apt metadata (which is now weeks out of date and likely will error)