官术网_书友最值得收藏!

Managing application configuration

The goal of packaging applications in Docker images is to use the same image in every environment. You don't build separate images for test and production, because that would make them separate apps and there could be inconsistencies between them. You should deploy your production app from the exact same Docker image that was tested by the users, which is the exact same image generated by the build process and used for all of your automated integration tests.

Of course, some things need to change between environments – connection strings for the database, logging level, and feature switches. This is application configuration, and in the Docker world you build your application image with a default set of configuration, typically for the development environment.  At runtime you inject the correct configuration for the current environment into the container, and that overwrites the default configuration.

There are different approaches to injecting this configuration. In this chapter I'll show you how to use volume mounts and environment variables. In production, you'll be running a cluster of machines running Docker, and you can store configuration data in the cluster's secure database, as Docker config objects or Docker secrets. I'll cover this in Chapter 7, Orchestrating Distributed Solutions with Docker Swarm.

主站蜘蛛池模板: 泉州市| 大悟县| 闻喜县| 卢氏县| 滨州市| 安陆市| 上思县| 赤水市| 香格里拉县| 镇江市| 乳山市| 津南区| 泽库县| 城口县| 沁阳市| 丹阳市| 石嘴山市| 普格县| 商都县| 罗江县| 北京市| 阜康市| 亳州市| 云龙县| 双鸭山市| 谢通门县| 德昌县| 翼城县| 石门县| 乌鲁木齐县| 青田县| 清新县| 庄浪县| 松阳县| 舞阳县| 新田县| 资中县| 平昌县| 西昌市| 黔西县| 新兴县|