Edit

Share via


Troubleshoot Visual Studio development with Docker

Applies to: Visual Studio

When you work with Visual Studio Container Tools, you might encounter problems while building or debugging your application. This article introduces some common troubleshooting steps for these problems.

Volume sharing isn't enabled. Enable volume sharing in the Docker CE for Windows settings (Linux containers only)

You only need to manage file sharing if you're using Hyper-V with Docker. If you're using WSL 2, you don't need to follow the steps in this section, and the file sharing option isn't visible. To resolve this problem:

  1. Right-click Docker for Windows in the notification area, and then select Settings.

  2. Select Resources > File Sharing and share the folder that needs to be accessed. Sharing your entire system drive is possible but not recommended.

    Screenshot of shared drives.

Tip

Visual Studio prompts you when Shared Drives aren't configured.

Problems with paths on Windows containers

When you use file paths that are specific to Linux on a Windows container, you might encounter various file input or output (I/O) errors. If you see these errors, check the value of the environment variable VSCT_WslDaemon. If the variable is set, Visual Studio attempts to use Windows Subsystem for Linux (WSL) paths to refer to the Windows files for creating volumes. This approach is necessary for Docker in WSL, but it doesn't work with Docker Desktop on Windows. Always unset this environment variable if you use Windows containers.

Unable to start debugging

One reason for this problem is stale debugging components in your user profile folder. Run the following commands to remove these folders so that the latest debugging components are downloaded in the next debug session.

  • del %userprofile%\vsdbg
  • del %userprofile%\onecoremsvsmon

Errors specific to networking when debugging your application

Try executing the script downloadable from Cleanup Container Host Networking, which refreshes the network-related components on your host machine.

Mounts denied

When using Docker for macOS, you might encounter an error referencing the folder /usr/local/share/dotnet/sdk/NuGetFallbackFolder. Add the folder to the File Sharing tab in Docker.

Docker users group

You might encounter the following error in Visual Studio when working with containers:

The current user must be in the 'docker-users' group to use Docker Desktop. Add yourself to the 'docker-users' group and then log out of Windows.

You must be a member of the 'docker-users' group to have permissions to work with Docker containers. To add yourself to the group in Windows 10 or later, follow these steps:

  1. From the Start menu, open Computer Management.
  2. Expand Local Users and Groups, and select Groups.
  3. Find the docker-users group, right-click and select Add to group.
  4. Add your user account or accounts.
  5. Sign out and sign back in again for these changes to take effect.

You can also use the net localgroup command at the Administrator command prompt to add users to specific groups.

net localgroup docker-users DOMAIN\username /add

In PowerShell, use the Add-LocalGroupMember function.

Low disk space

By default, Docker stores images in the %ProgramData%/Docker/ folder, which is typically on the system drive, C:\ProgramData\Docker\. To prevent images from taking up valuable space on the system drive, you can change the image folder location. To change the location:

  1. Right-click the Docker icon on the task bar and select Settings.

  2. Select Docker Engine.

  3. In the editing pane, add the graph property setting with the value of your desired location for Docker images:

       "graph": "D:\\mypath\\images"
    

    Screenshot of Docker File Sharing.

  4. Select Apply & Restart. These steps modify the configuration file at %ProgramData%\docker\config\daemon.json. Previously built images aren't moved.

Container type mismatch

When you add Docker support to a project, you choose either a Windows or a Linux container. If the Docker Server host isn't configured to run the same container type as the project target, you see an error similar to:

Screenshot of Docker Host and Project Mismatch.

To resolve this problem, right-click the Docker for Windows icon in the System Tray and select Switch to Windows containers... or Switch to Linux containers....

ContainerToolsPackage or DockerComposePackage didn't load correctly

A corrupted Managed Extensibility Framework (MEF) cache can cause this problem. To fix it, delete the ComponentModelCache folder for your Visual Studio instance.

  1. Close all instances of Visual Studio.

  2. Run the following PowerShell command to delete the ComponentModelCache folder:

    Get-ChildItem -Path "$(Join-Path $Env:LOCALAPPDATA "Microsoft\VisualStudio")" -Recurse -Include "ComponentModelCache" | Remove-Folder
    

You can also delete the folder manually:

  1. Open %localappdata%\Microsoft\VisualStudio in File Explorer.
  2. Open the subfolder that corresponds to your Visual Studio version (for example, 18.0_b653d53f).
  3. Delete the ComponentModelCache folder.

Other problems

For any other problems you encounter, see Microsoft/DockerTools.

References