121
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
Overriding the base docker-compose file
You could use a single docker-compose.yml file as in the simplified examples
shown in previous
sections. However, that is not recommended for most applications.
By default, Compose reads two files, a docker-compose.yml
and an optional docker-
compose.override.yml file. As shown in Figure 6-11, when you are using Visual Studio and enabling
Docker support, Visual Studio also creates an additional docker-compose.vs.debug.g.yml
file for
debugging the application, you can take a look at this file in folder obj\Docker\ in the main solution
folder.
Figure 6-11. docker-compose files in Visual Studio 2019
docker-compose
project file structure:
•
.dockerignore
- used to ignore files
•
docker-compose.yml
- used to compose microservices
•
docker-compose.override.yml
- used to configure microservices environment
You can edit the docker-compose files with any editor, like Visual Studio Code or Sublime,
and run the
application with the docker-compose up command.
By convention, the docker-compose.yml file contains your base configuration and other static
settings. That means that the service configuration should not change depending on the deployment
environment you are targeting.
The docker-compose.override.yml file,
as its name suggests, contains configuration settings that
override the base configuration, such as configuration that depends on the deployment environment.
You can have multiple override files with different names also. The override files usually contain
additional information needed by the application but specific to an environment or to a deployment.
Dostları ilə paylaş: