Executing the docker-compose command

To run the catalog service locally, we must complete the compose process from the CLI using the docker-compose command. It is possible to get an overview of the commands by running docker-compose --help.

The main commands related to the composition of a multi-container application are as follows:

  • docker-compose build: This builds the services. It executes the build using the Dockerfile associated with the images.
  • docker-compose images: This lists the current container images.
  • docker-compose up: This creates and runs the containers.
  • docker-compose config: This validates and views the docker-compose.yml file.

We can proceed by running the catalog service using the following command:

docker-compose up --build

By specifying the --build flag, it is possible to trigger the build before running the containers. Once the build is made, we can just run the docker-compose up command until our code changes and we need to rebuild the project.

Although we are now able to run our service using containers, the build and run process is not optimized: we are copying all of the files in the solution into the container; on top of that, we are running the container using the whole SDK of .NET Core, which is not needed if we want to run the project. In the next section, we will see how to optimize the containerization process to be more lightweight.

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

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