- sqldata
sqldata:
image:
mcr.microsoft.com/mssql/server:latest
environment:
- SA_PASSWORD=Pass@word
- ACCEPT_EULA=Y
ports:
- "5433:1433"
This docker-compose.yml file is a simplified and merged version. It contains static configuration data
for each container (like the name of the custom image), which is always required, and configuration
information that might depend on the deployment environment, like the connection string. In later
sections, you will learn how to split the docker-compose.yml configuration into multiple docker-
compose files and override values depending on the environment and execution type (debug or
release).
The docker-compose.yml file example defines four services: the
webmvc
service (a web application),
two microservices (
ordering-api
and
basket-api
), and one data source container,
sqldata
, based on
SQL Server for Linux running as a container. Each service will be deployed as a container, so a Docker
image is required for each.
The docker-compose.yml file specifies not only what containers are being used, but how they are
individually configured. For instance, the
webmvc
container definition in the .yml file:
•
Uses a pre-built
eshop/web:latest
image. However, you could also configure the image to be
built as part of the docker-compose execution with an additional configuration based on a build:
section in the docker-compose file.
•
Initializes two environment variables (CatalogUrl and OrderingUrl).
•
Forwards the exposed port 80 on the container to the external port 80 on the host machine.
•
Links the web app to the catalog and ordering service with the depends_on setting. This causes
the service to wait until those services are started.
We will revisit the docker-compose.yml file in a later section when we cover how to implement
microservices and multi-container apps.