Running the cart service using Docker

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:alpinenetworks:    my_network:        driver: bridge

First, the preceding ...

Get Hands-On RESTful Web Services with ASP.NET Core 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.