DCA · Question #32
An application image runs in multiple environments, and each environment uses different certificates and ports, what is the best practice to deploy the containers?
The correct answer is D. Create a config file for each environment. The best practice for deploying containers with environment-specific configurations, such as different certificates and ports, is to externalize these settings into configuration files.
Question
An application image runs in multiple environments, and each environment uses different certificates and ports, what is the best practice to deploy the containers?
Options
- ACreate a Dockerfile for each environment, specifying ports and ENV variables for certificates.
- BCreate a Dockerfile for each environment, specifying ports and Docker secrets for certificates.
- CCreate images that contain the specific configuration for every environment.
- DCreate a config file for each environment.
How the community answered
(54 responses)- A7% (4)
- B15% (8)
- C4% (2)
- D74% (40)
Why each option
The best practice for deploying containers with environment-specific configurations, such as different certificates and ports, is to externalize these settings into configuration files.
Creating a Dockerfile for each environment leads to multiple similar images, violating the 'build once, run anywhere' principle and increasing maintenance overhead.
While Docker secrets are suitable for sensitive data, creating separate Dockerfiles for each environment to embed these is inefficient and contradicts the goal of a single, reusable image.
Creating distinct images for every environment results in image proliferation, making the build and deployment process less efficient and harder to manage due to redundant image builds.
By externalizing environment-specific configurations into separate config files, the core application image remains immutable and generic. This approach allows the same image to be deployed across multiple environments with different settings applied at runtime, promoting consistency and easier management.
Concept tested: Container configuration best practices and immutability
Source: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#decouple-applications-from-configuration
Topics
Community Discussion
No community discussion yet for this question.