The tools included in Visual Studio for developing with Docker containers greatly simplify building, debugging, and deployment for containerized applications. You can work with a container for a single project, or use container orchestration with Docker Compose or Service Fabric to work with multiple services in containers.
Docker support is available for ASP.NET projects, ASP.NET Core projects, and .NET Core and .NET Framework console projects.
The support for Docker in Visual Studio has changed over a number of releases in response to customer needs. There are two levels of Docker support you can add to a project, and the supported options vary by the type of project and the version of Visual Studio. With some supported project types, if you just want a container for a single project, without using orchestration, you can do that by adding Docker support. The next level is container orchestration support, which adds appropriate support files for the particular orchestrator you choose.
With Visual Studio 2019, you can use Docker Compose, Kubernetes, and Service Fabric as container orchestration services.
In Visual Studio 2019 version 16.4 and later, the Containers window is available, which lets you view running containers, browse available images, view environment variables, logs, and port mappings, inspect the filesystem, attach a debugger, or open a terminal window inside the container environment. See Use the Containers window.
Docker support is available for ASP.NET projects, ASP.NET Core projects, and .NET Core and .NET Framework console projects.
The support for Docker in Visual Studio has changed over a number of releases in response to customer needs. There are several options to add Docker support to a project, and the supported options vary by the type of project and the version of Visual Studio. With some supported project types, if you just want a container for a single project, without using orchestration, you can do that by adding Docker support. The next level is container orchestration support, which adds appropriate support files for the particular orchestrator you choose.
With Visual Studio 2022 version 17.9 and later, when you add Docker support to a .NET 7 or later project, you have two container build types to choose from for adding Docker support. You can choose to add a Dockerfile to specify how to build the container images, or you can choose to use the built-in container support provided by the .NET SDK.
Also, with Visual Studio 2022 and later, when you choose container orchestration, you can use Docker Compose or Service Fabric as container orchestration services.
In Visual Studio 2022, the Containers window is available, which lets you view running containers, browse available images, view environment variables, logs, and port mappings, inspect the filesystem, attach a debugger, or open a terminal window inside the container environment. See Use the Containers window.
To create a project with Docker support, or add Docker support to an existing project, see Add Docker support.
ملاحظة
Docker's licensing requirements might be different for different versions of Docker Desktop. Refer to the Docker documentation to understand the current licensing requirements for using your version of Docker Desktop for development in your situation.
Containers window
The Containers window lets you view containers and images on your machine and see what's going on with them. You can view the filesystem, volumes mounted, environment variables, ports used, and examine log files.
Open the Containers window by using the quick launch (Ctrl+Q) and typing containers. You can use the docking controls to put the window somewhere. Because of the width of the window, it works best when docked at the bottom of the screen.
Select a container, and use the tabs to view the information that's available. To check it out, run your Docker-enabled app, open the Files tab, and expand the app folder to see your deployed app on the container.
When you want to compose a multi-container solution using Docker Compose, add container orchestrator support to your projects. This lets you run and debug a group of containers (a whole solution or group of projects) at the same time if they're defined in the same docker-compose.yml file.
To add container orchestrator support using Docker Compose, right-click on the project node in Solution Explorer, and choose Add > Container Orchestrator Support. Then choose Docker Compose to manage the containers.
After you add container orchestrator support to your project, you see a Dockerfile added to the project (if there wasn't one there already) and a docker-compose folder added to the solution in Solution Explorer, as shown here:
If docker-compose.yml already exists, Visual Studio just adds the required lines of configuration code to it.
Repeat the process with the other projects that you want to control using Docker Compose.
If you work with a large number of services, you can save time and computing resources by selecting which subset of services you want to start in your debugging session. See Start a subset of Compose services.
ملاحظة
Remote Docker hosts are not supported in Visual Studio tooling.
Service Fabric support
With Service Fabric tools in Visual Studio, you can develop and debug for Azure Service Fabric, run and debug locally, and deploy to Azure.
Visual Studio 2019 and later support developing containerized microservices using Windows containers and Service Fabric orchestration.
For more information on Azure Service Fabric, see Service Fabric.
Continuous delivery and continuous integration (CI/CD)
Visual Studio integrates readily with Azure Pipelines for automated and continuous integration and delivery of changes to your service code and configuration. To get started, see Create your first pipeline.
إنشاء وتكوين بيئة تطوير كاملة الميزات المستندة إلى الحاوية مع ملحق Visual Studio Code Dev Containers. افتح أي مجلد أو ملف في حاوية واستفد من مجموعة الميزات الكاملة من Visual Studio Code مثل IntelliSense (الإكمال)، التنقل في التعليمات البرمجية، وتصحيح الأخطاء.
تقيس هذه الشهادة قدرتك على إنجاز المهام التقنية التالية: تصميم وتنفيذ العمليات والاتصالات، وتصميم وتنفيذ استراتيجية التحكم بالمصادر، وتصميم وتنفيذ البنية الأساسية لبرنامج ربط العمليات التجارية للإنشاء والإصدار، وتطوير خطة أمان وتوافق، وتنفيذ استراتيجية تقرير عن حالة النظام.