Docker ~ Relationship between docker-compose and VS solutions, and docker Network Solutions
Back to directory
Generally, after adding a solution to VS, We will update the module or business to add multiple APIs and web projects. This is similar to the microservice mentioned recently, our docker-compose has a tacit understanding with Microsoft. When you add docker support for your solution, you will release a docker-compose, it will integrate and manage all the projects that can be released, and then let you publish a batch of your images with one click. Here we call it "service" and we can delete this service, stop, run it, very convenient!
Uncle's understanding of docker-compose
Relationship between docker-compose and VS Solutions
A solution corresponds to a docker-compose project, which consists of the docker-compose.yml and its sub-file components that are used to supplement it!
Relationship between docker-compose and VS and projects
A docker-compose includes all the projects that can be released. These projects are called a service in compose!
Relationship between Dockerfile and VS Project
A Dockerfile corresponds to a specific project, such as websites, APIs, and console programs. It mainly publishes and runs them!
Relationship between docker-compose and Dockerfile
A docker-compose includes multiple dockerfiles, and each Dockerfile corresponds to an image. That is to say, many image components have a service, a docker-compose, we can divide services according to our own rules. The minimum management unit of docker-compose is "service "!
Example
Docker-compose.yml
version: '2'services: coremvc1.1: image: coremvc1.1 build: context: ./coreMvc1.1 dockerfile: Dockerfile shop: image: shop build: context: ./Shop dockerfile: Dockerfile
Function supplement of docker-compose.override.yml for original file
version: '2'services: coremvc1.1: environment: - ASPNETCORE_ENVIRONMENT=Development ports: - "80" shop: environment: - ASPNETCORE_ENVIRONMENT=Development ports: - "80"
Then release the entire solution and copy it to your linux environment.
Run docker-compose build to generate a service, which is a batch of images that can be viewed through docker-compose images.
After the container is generated successfully, run docker-compose up to run the services. Then, run docker ps or docker-compose ps to view the running containers.
From the figure above, we can see that this service includes two containers, listening to ports 81 and 82 respectively, and their own program ports are both 5000, which is also the default!
Sometimes, I think Microsoft and vs2017 are too considerate for developers!
Thank you for reading this article!
Back to directory