- Visual Studio Docker Image
- Visual Studio Docker Project
- Visual Studio Docker C++
- Visual Studio Docker Compose
- Visual Studio Docker Tools
- Visual Studio Community
You can customize how Visual Studio builds your container projects by setting the properties that MSBuild uses to build your project. For example, you can change the name of the Dockerfile, specify tags and labels for your images, provide additional arguments passed to Docker commands, and control whether Visual Studio does certain performance optimizations such as building outside of the container environment. You can also set debugging properties such as the name of the executable to launch, and the command line arguments to provide.
To set the value of a property, edit the project file. For example, suppose your Dockerfile is named MyDockerfile. You can set the DockerfileFile
property in the project file as follows.
You can add the property setting to an existing PropertyGroup
element, or if there isn't one, create a new PropertyGroup
element.
2 days ago This tutorial provides instructions for how to create a container application using Microsoft. Visual Studio Code (VS Code) and deploy it to the DE10-Nano. In this tutorial, you will learn you learn how to: Set up Visual Studio Code for developing an IoT Edge container application; Set up a cross-compiling environment with buildx. By default, Docker Compose automatically creates a network specifically for the application stack (which is why you didn't define one in the compose file). Look at the logs using the docker-compose logs -f command. You'll see the logs from each of the services interleaved into a single stream.
The following table shows the MSBuild properties available for container projects. The NuGet package version applies to Microsoft.VisualStudio.Azure.Containers.Tools.Targets.
Property name | Description | Default value | NuGet package version |
---|---|---|---|
ContainerDevelopmentMode | Controls whether 'build-on-host' optimization ('Fast Mode' debugging) is enabled. Allowed values are Fast and Regular. | Fast | 1.0.1872750 or newer |
ContainerVsDbgPath | The path for VSDBG debugger. | %USERPROFILE%vsdbgvs2017u5 | 1.0.1985401 or newer |
DockerDebuggeeArguments | When debugging, the debugger is instructed to pass these arguments to the launched executable. | Not applicable to ASP.NET .NET Framework projects | 1.7.8 or newer |
DockerDebuggeeProgram | When debugging, the debugger is instructed to launch this executable. | For .NET Core projects: dotnet, ASP.NET .NET Framework projects: Not applicable (IIS is always used) | 1.7.8 or newer |
DockerDebuggeeKillProgram | This command is used to kill the running process in a container. | Not applicable to ASP.NET .NET Framework projects | 1.7.8 or newer |
DockerDebuggeeWorkingDirectory | When debugging, the debugger is instructed to use this path as the working directory. | C:app (Windows) or /app (Linux) | 1.7.8 or newer |
DockerDefaultTargetOS | The default target operating system used when building the Docker image. | Set by Visual Studio. | 1.0.1985401 or newer |
DockerImageLabels | The default set of labels applied to the Docker image. | com.microsoft.created-by=visual-studio;com.microsoft.visual-studio.project-name=$(MSBuildProjectName) | 1.5.4 or newer |
DockerFastModeProjectMountDirectory | In Fast Mode, this property controls where the project output directory is volume-mounted into the running container. | C:app (Windows) or /app (Linux) | 1.9.2 or newer |
DockerfileBuildArguments | Additional arguments passed to the Docker build command. | Not applicable. | 1.0.1872750 or newer |
DockerfileContext | The default context used when building the Docker image, as a path relative to the Dockerfile. | Set by Visual Studio. | 1.0.1872750 or newer |
DockerfileFastModeStage | The Dockerfile stage (that is, target) to be used when building the image in debug mode. | First stage found in the Dockerfile (base) | |
DockerfileFile | Describes the default Dockerfile that will be used to build/run the container for the project. This can be a path as well. | Dockerfile | 1.0.1872750 or newer |
DockerfileRunArguments | Additional arguments passed to the Docker run command. | Not applicable. | 1.0.1872750 or newer |
DockerfileRunEnvironmentFiles | Semicolon-delimited list of environment files applied during Docker run. | Not applicable. | 1.0.1872750 or newer |
DockerfileTag | The tag that will be used when building the Docker image. In debugging, a ':dev' is appended to the tag. | Assembly name after stripping non-alphanumeric characters with the following rules: If the resultant tag is all numeric, then 'image' is inserted as a prefix (for example, image2314) If the resultant tag is an empty string, then 'image' is used as the tag. | 1.0.1872750 or newer |
Example
The following project file shows examples of some of these settings.
Next steps
For information on MSBuild properties generally, see MSBuild Properties.
See also
The Docker extension makes it easy to build, manage, and deploy containerized applications from Visual Studio Code.
This page provides an overview of the Docker extension capabilities; use the side menu to learn more about topics of interest. If you are just getting started with Docker development, try the Docker tutorial first to understand key Docker concepts.
Installation
Install Docker on your machine and add it to the system path.
Visual Studio Docker Image
On Linux, you should also enable Docker CLI for the non-root user account that will be used to run VS Code.
To install the extension, open the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)), search for docker
to filter results and select Docker extension authored by Microsoft.
Editing Docker files
You can get IntelliSense when editing your Dockerfile
and docker-compose.yml
files, with completions and syntax help for common commands.
Visual Studio Docker Project
In addition, you can use the Problems panel (⇧⌘M (Windows, Linux Ctrl+Shift+M)) to view common errors for Dockerfile
and docker-compose.yml
files.
Generating Docker files
You can add Docker files to your workspace by opening the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) and using Docker: Add Docker Files to Workspace command. The command will generate Dockerfile
and .dockerignore
files and add them to your workspace. The command will also query you if you want the Docker Compose files added as well; this is optional.
The extension recognizes workspaces that use most popular development languages (C#, Node.js, Python, Ruby, Go, and Java) and customizes generated Docker files accordingly.
Docker Explorer
The Docker extension contributes a Docker Explorer view to VS Code. The Docker Explorer lets you examine and manage Docker assets: containers, images, volumes, networks, and container registries. If the Azure Account extension is installed, you can browse your Azure Container Registries as well.
The right-click menu provides access to commonly used commands for each type of asset.
You can rearrange the Docker Explorer panes by dragging them up or down with a mouse and use the context menu to hide or show them.
Docker commands
Spa condor driver. Many of the most common Docker commands are built right into the Command Palette:
Visual Studio Docker C++
You can run Docker commands to manage images, networks, volumes, image registries, and Docker Compose. In addition, the Docker: Prune System command will remove stopped containers, dangling images, and unused networks and volumes.
Using image registries
You can display the content and push/pull/delete images from Azure Container Registry, Docker Hub, GitLab, and more:
An image in an Azure Container Registry can be deployed to Azure App Service directly from VS Code; see Deploy images to Azure App Service page. For more information about how to authenticate to and work with registries see Using container registries page.
Debugging services running inside a container
You can debug services built using .NET (C#) and Node.js that are running inside a container. The extension offers custom tasks that help with launching a service under the debugger and with attaching the debugger to a running service instance. For more information see Debug container application and Extension Properties and Tasks pages.
Azure CLI integration
You can start Azure CLI (command-line interface) in a standalone, Linux-based container with Docker Images: Run Azure CLI command. This allows access to full Azure CLI command set in an isolated environment. See Get started with Azure CLI page for more information on available commands.
Docker Compose
Toshiba hard disk controller driver. Docker Compose lets you define and run multi-container applications with Docker. You can define what shape these containers look like with a file called docker-compose.yml
.
Visual Studio Code's experience for authoring docker-compose.yml
is also very rich, providing IntelliSense for valid Docker compose directives and it will query Docker Hub for metadata on public Docker images.
- Create a new file in your workspace called
docker-compose.yml
- Define a new service called
web:
- On the second line, bring up IntelliSense by pressing ⌃Space (Windows, Linux Ctrl+Space) to see a list of all valid compose directives.
- For the
image
directive, you can press ⌃Space (Windows, Linux Ctrl+Space) again and VS Code will query the Docker Hub index for public images.
VS Code will first show a list of popular images along with metadata such as the number of stars and description. If you continue typing, VS Code will query the Docker Hub index for matching images, including searching public profiles. For example, searching for 'Microsoft' will show you all the public Microsoft images.
Visual Studio Docker Compose
Visual Studio Docker Tools
Next steps
Visual Studio Community
Read on to learn more about