DCA · Question #34
From a DevOps process standpoint, it is best practice to keep changes to an application in version control. Which of the following will allow changes to a docker Image to be stored in a version…
The correct answer is D. A dockerfile. To store changes to a Docker image in a version control system according to DevOps best practices, a Dockerfile is the appropriate method.
Question
From a DevOps process standpoint, it is best practice to keep changes to an application in version control. Which of the following will allow changes to a docker Image to be stored in a version control system?
Options
- Adocker commit
- Bdocker save
- CA docker-compose.yml file
- DA dockerfile
How the community answered
(37 responses)- A3% (1)
- C5% (2)
- D92% (34)
Why each option
To store changes to a Docker image in a version control system according to DevOps best practices, a Dockerfile is the appropriate method.
The `docker commit` command creates a new image from a running container's state, but the changes are not recorded in a human-readable, version-controlled script, making it non-reproducible and an anti-pattern for version control.
The `docker save` command exports an image to a tar archive, which is a binary representation of the image and cannot be version-controlled in terms of its changes or definitions.
A `docker-compose.yml` file defines how multi-container applications are run and orchestrated, but it does not specify how individual Docker images are built or track their internal changes for version control.
A Dockerfile provides a scriptable, declarative definition of how an image is built, including its base image, dependencies, and application code. Placing the Dockerfile under version control allows all changes to the image's definition to be tracked, ensuring reproducibility and enabling a consistent CI/CD pipeline.
Concept tested: Dockerfile for reproducible image builds and version control
Source: https://docs.docker.com/engine/reference/builder/
Topics
Community Discussion
No community discussion yet for this question.