Given the following excerpt of a Dockerfile:
Run apt-get ""y update && apt-get install ""y fortunes && apt-get clean
Why are the multiple apt-get commands combined in one RUN statement instead of using multiple RUN statements?
Given the following excerpt of a Dockerfile:
Run apt-get ""y update && apt-get install ""y fortunes && apt-get clean
Why are the multiple apt-get commands combined in one RUN statement instead of using multiple RUN statements?
Combining multiple apt-get commands in a single RUN statement helps to avoid the creation of unnecessary images. Docker creates a new image layer for each RUN statement. By combining commands, all actions are executed in one layer, which minimizes the number of layers and helps keep the Docker image smaller and more efficient.
Correct is C. Minimize the number of layers In older versions of Docker, it was important that you minimized the number of layers in your images to ensure they were performant. The following features were added to reduce this limitation: Only the instructions RUN, COPY, ADD create layers. Other instructions create temporary intermediate images, and do not increase the size of the build. Where possible, use multi-stage builds, and only copy the artifacts you need into the final image. This allows you to include tools and debug information in your intermediate build stages without increasing the size of the final image.
hello,can i find another practice exam
"C" is the correct answer
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
Ans D. Using RUN apt-get update && apt-get install -y ensures your Dockerfile installs the latest package versions with no further coding or manual intervention. This technique is known as “cache busting”. You can also achieve cache-busting by specifying a package version. This is known as version pinning, https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
I agree, the correct answer is C
From: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers Only the instructions RUN, COPY, ADD create layers. Other instructions create temporary intermediate images, and do not increase the size of the build.
Correct is C
I think is D.