Breaking

Friday, June 18, 2021

Visual Studio 2019 - Create a Docker compose file for an existing solution

Visual Studio makes it really easy to create a Docker compose file for an existing solution.

Here are the steps to get there:

  • Open your solution in Visual Studio
  • Right click on one of your projects and choose Add –> Container Orchestrator Support
  • Choose Docker compose in the Add Container Orchestrator dialog and click OK
  • Choose Linux as the Target OS and click OK
  • A new Docker Compose project is generated
  • Inside this project you find a docker-compose.yml file with a reference to the project you’ve selected
version: '3.4'
services:
frontend:
image: ${DOCKER_REGISTRY-}frontend
build:
context: .
dockerfile: DockerComposeExample/Dockerfile
  • To add the other projects, follow the same procedure; right click on another project and choose Add –> Container Orchestrator Support again
  • The docker-compose.yml file will be updated with the new project information
version: '3.4'
services:
frontend:
image: ${DOCKER_REGISTRY-}frontend
build:
context: .
dockerfile: DockerComposeExample/Dockerfile
backend:
image: ${DOCKER_REGISTRY-}backend
build:
context: .
dockerfile: Backend/Dockerfile

No comments:

Post a Comment