Configuring application environments

When you define your application in Docker Compose, you have a single artifact that describes all the components of the application and the integration points between them. This is often referred to as the application manifest—a document that lists all the parts of your app. In the same way that the Dockerfile explicitly defines the steps to install and configure one piece of software, the Docker Compose file explicitly defines the steps to deploy the whole solution.

Docker Compose also lets you capture application definitions that can be deployed to different environments, so your Compose files are usable throughout the deployment pipeline. Usually, there are differences between environments, either in the infrastructure setup or the application settings. Docker Compose gives you two options to manage these environmental differences—using external resources, or using override files.

Infrastructure typically differs between production and non-production environments, which affects volumes and networks in Docker applications. On a development laptop, your database volume may be mapped to a known location on the local disk, which you periodically clean up. In production, you could have a volume plugin for a shared storage hardware device. Similarly, with networks, production environments may need to be explicit about subnet ranges, which are not a concern in development.

Docker Compose lets you specify resources as being external to the Compose file, so the application will use resources that already exist. These resources need to be created in advance, but that means each environment can be configured differently and still use the same Compose file.

Compose also supports an alternative approach, where you explicitly capture the configuration of your resources for each environment in different Compose files and use multiple Compose files when you run the application. I'll demonstrate both of these options. As with other design decisions, Docker doesn't impose specific practices, and you can use whichever best suits your processes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.244.250