f you already have one or more Dockerfiles, you can add Docker Compose files by opening the Command Palette (Ctrl+Shift+P), and using the Docker: Add Docker Compose Files to Workspace command. Follow the prompts.
You can add Docker Compose files to your workspace at the same time you add a Dockerfile by opening the Command Palette (Ctrl+Shift+P) and using the Docker: Add Docker Files to Workspace command. You’ll be asked if you want to add Docker Compose files. If you want to keep your existing Dockerfile, choose No when prompted to overwrite the Dockerfile.
The Docker extension adds the docker-compose.yml file to your workspace. This file contains the configuration to bring up the containers as expected in production. In some cases, a docker-compose.debug.yml is also generated. This file provides a simplified mode for starting that enables the debugger.
Screenshot of project with docker-compose files
The VS Code Docker extension generates files that work out of the box, but you can also customize them to optimize for your scenario. You can then use the Docker Compose Up command (right-click on the docker-compose.yml file, or find the command in the Command Palette) to get everything started at once. You can also use the docker-compose up command from the command prompt or terminal window in VS Code to start the containers. Refer to the Docker Compose documentation about how to configure the Docker Compose behavior and what command-line options are available.
With the docker-compose files, you can now specify port mappings in the docker-compose files, rather than in the .json configuration files. For examples, see the Docker Compose documentation.