Let's learn how to run the previously implemented cart service using Docker. As we described in the previous chapter, we are going to define the docker-compose.yml file and the Dockerfile in the root of the cart service project. The docker-compose file will define two containers: the first hosts the cart service ASP.NET Core instance, while the other represents the Redis instance:
version: "3.7"
services:
cart_api:
container_name: cart_api
build:
context: .
env_file:
- .env
networks:
- my_network
ports:
- 5002:5002
depends_on:
- cart_db
cart_db:
container_name: cart_db
networks:
- my_network
env_file:
- .env
ports:
- 6378:6378
image: redis:alpine
networks...