Documentation
Topics Overview Overview Linux macOS Windows VS Code for the Web Raspberry Pi Network Additional Components Uninstall VS Code Tutorial Copilot Quickstart User Interface Personalize VS Code Install Extensions Tips and Tricks Intro Videos Overview Setup Quickstart Overview Language Models Context Tools Agents Customization Trust & Safety Overview Agents Tutorial Agents Window Planning Memory Tools Subagents Local Agents Copilot CLI Cloud Agents Third-Party Agents Overview Chat Sessions Add Context Inline Chat Review Edits Checkpoints Artifacts Panel Debug Chat Interactions Prompt Examples Overview Instructions Prompt Files Custom Agents Agent Skills Language Models MCP Hooks Plugins Context Engineering Customize AI Test-Driven Development Edit Notebooks with AI Test with AI Test Web Apps with Browser Tools Debug with AI MCP Dev Guide OpenTelemetry Monitoring Inline Suggestions Smart Actions Best Practices Security Troubleshooting FAQ Cheat Sheet Settings Reference MCP Configuration Workspace Context Display Language Layout Keyboard Shortcuts Settings Settings Sync Extension Marketplace Extension Runtime Security Themes Profiles Overview Voice Interactions Command Line Interface Telemetry Basic Editing IntelliSense Code Navigation Refactoring Snippets Overview Multi-Root Workspaces Workspace Trust Tasks Debugging Debug Configuration Testing Port Forwarding Integrated Browser Overview Quickstart Staging & Committing Branches & Worktrees Repositories & Remotes Merge Conflicts Collaborate on GitHub Troubleshooting FAQ Getting Started Tutorial Terminal Basics Terminal Profiles Shell Integration Appearance Advanced Overview Enterprise Policies AI Settings Extensions Telemetry Updates Overview JavaScript JSON HTML Emmet CSS, SCSS and Less TypeScript Markdown PowerShell C++ Java PHP Python Julia R Ruby Rust Go T-SQL C# .NET Swift Working with JavaScript Node.js Tutorial Node.js Debugging Deploy Node.js Apps Browser Debugging Angular Tutorial React Tutorial Vue Tutorial Debugging Recipes Performance Profiling Extensions Tutorial Transpiling Editing Refactoring Debugging Quick Start Tutorial Run Python Code Editing Linting Formatting Debugging Environments Testing Python Interactive Django Tutorial FastAPI Tutorial Flask Tutorial Create Containers Deploy Python Apps Python in the Web Settings Reference Getting Started Navigate and Edit Refactoring Formatting and Linting Project Management Build Tools Run and Debug Testing Spring Boot Modernizing Java Apps Application Servers Deploy Java Apps GUI Applications Extensions FAQ Intro Videos GCC on Linux GCC on Windows GCC on Windows Subsystem for Linux Clang on macOS Microsoft C++ on Windows Build with CMake CMake Tools on Linux CMake Quick Start C++ Dev Tools for Copilot Editing and Navigating Debugging Configure Debugging Refactoring Settings Reference Configure IntelliSense Configure IntelliSense for Cross-Compiling FAQ Intro Videos Get Started Navigate and Edit IntelliCode Refactoring Formatting and Linting Project Management Build Tools Package Management Run and Debug Testing FAQ Overview Node.js Python ASP.NET Core Debug Docker Compose Registries Deploy to Azure Choose a Dev Environment Customize Develop with Kubernetes Tips and Tricks Overview Jupyter Notebooks Data Science Tutorial Python Interactive Data Wrangler Quick Start Data Wrangler PyTorch Support Azure Machine Learning Manage Jupyter Kernels Jupyter Notebooks on the Web Data Science in Microsoft Fabric Foundry Toolkit Overview Foundry Toolkit Copilot Tools Create Agents Models Playground Agent Builder Agent Inspector Evaluation Tool Catalog Fine-Tuning (Automated Setup) Fine-Tuning (Project Template) Model Conversion Tracing Profiling (Windows ML) FAQ File Structure Manual Model Conversion Manual Model Conversion on GPU Setup Environment Without Foundry Toolkit Template Project Migrating from Visualizer to Agent Inspector Overview Getting Started Resources View Deployment VS Code for the Web - Azure Containers Azure Kubernetes Service Kubernetes MongoDB Remote Debugging for Node.js Overview SSH Dev Containers Windows Subsystem for Linux GitHub Codespaces VS Code Server Tunnels SSH Tutorial WSL Tutorial Tips and Tricks FAQ Overview Tutorial Attach to Container Create Dev Container Advanced Containers devcontainer.json Dev Container CLI Tips and Tricks FAQ Default Keyboard Shortcuts Default Settings Substitution Variables Tasks SchemaOn this page there are 7 sections
Customize the Container Tools extension
The Container Tools extension includes several Visual Studio Code tasks to control the behavior of Docker build and run, and form the basis of container startup for debugging.
The tasks allow for a great deal of control and customization. The final configuration is a combination of general defaults, platform-specific defaults (such as Node.js, Python, or .NET), and user input. User input takes precedence when it conflicts with defaults.
All common features of Visual Studio Code tasks (for example, grouping tasks into compound tasks) are supported by Container Tools extension tasks. For more information on common task features and properties, see the Visual Studio Code custom task documentation.
Docker build task
The docker-build task builds images using the Docker command line (CLI). The task can be used by itself, or as part of a chain of tasks to run and/or debug an application within a container.
The most important configuration settings for the docker-build task are dockerBuild and platform:
- The dockerBuild object specifies parameters for the Docker build command. Values specified by this object are applied directly to Docker build CLI invocation.
- The platform property is a hint that changes how the docker-build task determines Docker build defaults.
See property reference for full list of all task properties.
Platform support
While the docker-build task in tasks.json can be used to build any image, the extension has explicit support (and simplified configuration) for Node.js, Python, and .NET Core.
Node.js (docker-build)
Minimal configuration using defaults
A Node.js-based image with no specific platform options can just set the platform property to node:
{ "tasks": [ { "type": "docker-build", "label": "docker-build", "platform": "python" } ] }Platform defaults
For Python-based images, the docker-build task infers the following options:
| dockerBuild.context | The default context is the workspace folder. |
| dockerBuild.dockerfile | The default Dockerfile path will be in the root of the workspace folder. |
| dockerBuild.tag | The base name of the root workspace folder. |
| dockerBuild.pull | Defaults to true in order to pull new base images before building. |
.NET (docker-build)
Minimal configuration using defaults
When you build a .NET-based image, you can omit the platform property and just set the netCore object (platform is implicitly set to netcore when netCore object is present). Note that appProject is a required property:
{ "version": "2.0.0", "tasks": [ { "label": "Run Node Image", "node": "docker-run", "platform": "node" } ] }Platform defaults
For Node.js-based images, the docker-run task infers the following options:
| dockerRun.command | Generated from the npm start script in the package.json (if it exists), else generated from the main property in the package.json. |
| dockerRun.containerName | Derived from the application package name. |
| dockerRun.image | The tag from a dependent docker-build task (if one exists) or derived from the application package name, itself derived from the name property within package.json or the base name of the folder in which it resides. |
Python (docker-run)
When building a Python-based image, you can omit the platform property and just set the python object (platform is implicitly set to python when python object is present)
Minimal configuration for Django Apps
{ "type": "docker-run", "label": "docker-run: debug", "dependsOn": ["docker-build"], "dockerRun": { "env": { "FLASK_APP": "path_to/flask_entry_point.py" } }, "python": { "args": ["run", "--no-debugger", "--no-reload", "--host", "0.0.0.0", "--port", "5000"], "module": "flask" } }Minimal configuration for General Apps
{ "version": "2.0.0", "tasks": [ { "label": "Run .NET Core Image", "type": "docker-run", "netCore": { "appProject": "${workspaceFolder}/project.csproj" } } ] }Platform defaults
For .NET-based images, the docker-run task infers the following options:
| dockerRun.containerName | Derived from the base name of the root workspace folder. |
| dockerRun.env | Adds the following environment variables as required: ASPNETCORE_ENVIRONMENT, ASPNETCORE_URLS, and DOTNET_USE_POLLING_FILE_WATCHER. |
| dockerRun.image | The tag from a dependent docker-build task (if one exists) or derived from the base name of the root workspace folder. |
| dockerRun.os | Linux |
| dockerRun.volumes | Adds the following volumes as required: the local application folder, the source folder, the debugger folder, the NuGet package folder, and NuGet fallback folder. |
Run task reference
Here are all properties available for configuring docker-run task. All properties are optional unless indicated otherwise.
| dockerRun | Options for controlling the docker run command executed (see below). Required unless platform is set. |
| platform | Determines the platform: .NET (netcore) or Node.js (node) and default settings for docker run command. |
| node | For Node.js projects, this controls various options (see below). |
| python | For Python projects, this controls various options (see below). |
| netCore | For .NET projects, this controls various options (see below). |
dockerRun object properties
| image | The name (tag) of the image to run. Required unless inferred from the platform. |
IMAGE |
| command | The command to run upon starting the container. Required, unless inferred from the platform. |
COMMAND [ARG...] |
| containerName | The name given to the started container. Required, unless inferred from the platform. |
--name |
| env | Environment variables set in the container. This is a list of key-value pairs. | -e or --env |
| envFiles | This is a list of .env files. | --env-file |
| labels | Labels given to the started container. This is a list of key-value pairs. | --label |
| network | The name of the network to which the container will be connected. | --network |
| networkAlias | The network-scoped alias for the started container. | --network-alias |
| os | Default is Linux, the other option is Windows. The container operating system used. | N/A |
| ports | The ports to publish (map) from container to host. This is a list of objects (see below). | -p or --publish |
| portsPublishAll | Whether to publish all ports exposed by the Docker image. Defaults to true if no ports are explicitly published. | -P |
| extraHosts | The hosts to add to the container for DNS resolution. This is a list of objects (see below). | --add-host |
| volumes | The volumes to map into the started container. This is a list of objects (see below). | -v or --volume |
| remove | Whether or not to remove the container after it stops. | --rm |
| customOptions | Any extra parameters to add before the image argument. No attempt is made to resolve conflicts with other options or validate this option. | (any) |
ports object properties
| containerPort | The port number bound on the container. Required. |
|
| hostPort | The port number bound on the host. | (randomly selected by Docker) |
| protocol | The protocol for the binding (tcp or udp). | tcp |
extraHosts object properties
| hostname | The hostname for DNS resolution. Required. |
| ip | The IP address associated with the above hostname. Required. |
volumes object properties
| localPath | The path on the local machine that will be mapped. Required. |
|
| containerPath | The path in the container to which the local path will be mapped. Required. |
|
| permissions | Permissions the container has on the mapped path. Can be ro (read-only) or rw (read-write). | Container dependent. |
node object properties (docker-run task)
| package | The path to the package.json file associated with the docker-run task. | The file package.json in the root workspace folder. |
| enableDebugging | Whether or not to enable debugging within the container. | false |
| inspectMode | Defines the initial interaction between the application and the debugger (default or break). The value default allows the application to run until the debugger attaches. The value break prevents the application from running until the debugger attaches. |
default |
| inspectPort | The port on which debugging should occur. | 9229 |
python object properties (docker-run task)
| args | Arguments passed to the Python app. | Platform dependent. Defaults of scaffolding shown above |
| debugPort | The port that the debugger will listen on. | 5678 |
| wait | Whether to wait for debugger to attach. | true |
| module | The Python module to run (only module or file should be chosen). | |
| file | The Python file to run (only module or file should be chosen). |
netCore object properties (docker-run task)
| appProject | The .NET project file (.csproj, .fsproj, etc.) associated with docker-run task. Required. |
| configureSsl | Whether to configure ASP.NET Core SSL certificates and other settings to enable SSL on the service in the container. |
| enableDebugging | Whether to enable the started container for debugging. This will infer additional volume mappings and other options necessary for debugging. |
Docker Compose task
The docker-compose task in tasks.json creates and starts containers using the Docker Compose command line (CLI). The task can be used by itself, or as part of a chain of tasks to debug an application within a container.
The most important configuration setting for the docker-compose task is dockerCompose:
- The dockerCompose object specifies parameters for the Docker Compose command. Values specified by this object are applied directly to Docker Compose CLI invocation.
See property reference for full list of all task properties.
Example configuration
{ "containers.commands.build": "docker build --rm -f \"${dockerfile}\" -t ${tag} \"${context}\"" }The second option is multiple templates that will be chosen based on the match regular expression, as well as user input.
For example, three templates are shown in the following example: