In a Dockerfile, which instruction is commonly used to produce a new layer by executing build-time commands?

Prepare for the Kubernetes Cloud Native Associate (KCNA) Certification test with engaging questions and detailed explanations. Perfect your knowledge and boost your confidence to pass the exam successfully!

Multiple Choice

In a Dockerfile, which instruction is commonly used to produce a new layer by executing build-time commands?

Explanation:
Running commands during the image build is what creates a new layer that records the resulting filesystem changes. The instruction that does this is the one that executes shell commands at build time, turning the modifications into a fresh layer in the image. For example, a statement like RUN apt-get update && apt-get install -y curl runs those commands and stores the resulting changes as a new layer. Other instructions have different roles: COPY adds files and creates a layer but doesn’t execute build-time commands to modify the filesystem; LABEL adds metadata; CMD specifies what runs when a container starts, which is at runtime, not during the build. So the instruction that produces a new layer by executing build-time commands is RUN.

Running commands during the image build is what creates a new layer that records the resulting filesystem changes. The instruction that does this is the one that executes shell commands at build time, turning the modifications into a fresh layer in the image. For example, a statement like RUN apt-get update && apt-get install -y curl runs those commands and stores the resulting changes as a new layer. Other instructions have different roles: COPY adds files and creates a layer but doesn’t execute build-time commands to modify the filesystem; LABEL adds metadata; CMD specifies what runs when a container starts, which is at runtime, not during the build. So the instruction that produces a new layer by executing build-time commands is RUN.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy