Text of code.visualstudio.com › docs › devcontainers › tips-and-tricks as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Dev Containers Tips and Tricks

AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. Dev Containers Tips and Tricks View as Markdown Ask in VS Code Ask in VS Code Insiders This article includes some tips and tricks for getting the Dev Containers extension up and running in different environments.

Alternate ways to install Docker You can use Docker with the Dev Containers extension in a few ways, including: Docker installed locally. Docker installed on a remote environment. Other Docker compliant CLIs, installed locally or remotely. While other CLIs may work, they are not officially supported. Note that attaching to a Kubernetes cluster only requires a properly configured kubectl CLI . You can learn more in the alternative Docker options doc .

Customize AI Chat Responses Custom instructions enable you to describe common guidelines or rules to get responses that match your specific coding practices and tech stack. You can use custom instructions with dev containers to give Copilot more information about the type of dev container you're connected to (like what kind of languages or toolchains are installed). You can achieve this in a few ways: Add "github.copilot.chat.codeGeneration.instructions" directly in your devcontainer.json We publish dev container resources (like images and Features ) to make the process of creating and connecting to dev containers even easier, and we now include custom instructions in these files.

Here is an example of custom instructions in the Python Feature. Use a copilot-instructions.md file just as you would locally Docker Desktop for Windows tips Docker Desktop for Windows works well in most setups, but there are a few "gotchas" that can cause problems. Here are some tips on avoiding them: Consider using the new Docker WSL 2 back-end on Windows 10 (2004+). If you are using Docker Desktop's WSL 2 back-end , you can use it to open folders inside WSL as well as locally.

Containers are also shared between Windows and inside WSL and this new engine is less susceptible to file sharing issues. See the quick start for details. Switch out of "Linux Containers on Windows (LCOW)" mode. While disabled by default, recent versions of Docker support Linux Containers on Windows (LCOW) that can allow you to use both Windows and Linux containers at the same time. However, this is a new feature, so you may encounter issues and the Dev Containers extension only supports Linux containers currently.

You can switch out of LCOW mode at any time by right-clicking on the Docker task bar item and selecting Switch to Linux Containers... from the context menu. Make sure your firewall allows Docker to set up a shared drive. Docker only needs to connect between two machine local IPs, but some firewall software may still block any drive sharing or the needed ports. Here are some tips that applied to older versions of Docker for Windows but should now be resolved.

If you run into strange behaviors due to a possible regression, these tips have solved problems in the past. Use an AD domain account or local administrator account when sharing drives. Do not use an AAD (email-based) account. AAD (email-based) accounts have well-known issues, as documented in Docker issue #132 and issue #1352 . If you must use an AAD account, create a separate local administrator account on your machine that you use purely for the purpose of sharing drives.

Follow the steps in this blog post to get everything set up. Stick with alphanumeric passwords to avoid drive sharing problems. When asked to share your drives on Windows, you will be prompted for the username and password of an account with admin privileges on the machine. If you are warned about an incorrect username or password, this may be due to special characters in the password. For example, ! , [ and ] are known to cause issues.

Change your password to alphanumeric characters to resolve. See this issue about Docker volume mounting problems for details. Use your Docker ID to sign in to Docker (not your email). The Docker CLI only supports using your Docker ID, so using your email can cause problems. See Docker issue #935 for details. If you are still having trouble, see the Docker Desktop for Windows troubleshooting guide . Enabling file sharing in Docker Desktop The VS Code Dev Containers extension can only automatically mount your source code into a container if your code is in a folder or drive shared with Docker.

If you open a dev container from a non-shared location, the container will successfully start but the workspace will be empty. Note that this step is not required with Docker Desktop's WSL 2 engine . To change Docker's drive and folder sharing settings: Windows: Right-click on the Docker task bar item and select Settings . Go to Resources > File Sharing and check the drive(s) where your source code is located. If you see a message about your local firewall blocking the sharing action, see this Docker KB article for next steps. macOS: Click on the Docker menu bar item and select Preferences .

Go to Resources > File Sharing . Confirm that the folder containing your source code is under one of the shared folders listed. Resolving Git line ending issues in containers (resulting in many modified files) Since Windows and Linux use different default line endings, Git may report a large number of modified files that have no differences aside from their line endings. To prevent this from happening, you can disable line ending conversion using a .gitattributes file or globally on the Windows side.

Typically adding or modifying a .gitattributes file in your repository is the most reliable way to solve this problem. Committing this file to source control will help others and allows you to vary behaviors by repository as appropriate. For example, adding the following to .gitattributes file to the root of your repository will force everything to be LF, except for Windows batch files that require CRLF: * text=auto eol=lf * . {cmd,[cC][mM][dD]} text eol=crlf * . {bat,[bB][aA][tT]} text eol=crlf Note that this works in Git v2.10+ , so if you are running into problems, be sure you've got a recent Git client installed.

You can add other file types in your repository that require CRLF to this same file. If you would prefer to still always upload Unix-style line endings (LF), you can use the input option. git config --global core.autocrlf input If you'd prefer to disable line-ending conversion entirely, run the following instead: git config --global core.autocrlf false Finally, you may need to clone the repository again for these settings to take effect.

Avoid setting up Git in a container when using Docker Compose See Sharing Git credentials with your container in the main containers article for information on resolving this issue. Resolving hangs when doing a Git push or sync from a Container If you clone a Git repository using SSH and your SSH key has a passphrase, VS Code's pull and sync features may hang when running remotely. Either use an SSH key without a passphrase, clone using HTTPS, or run git push from the command line to work around the issue.

Resolving errors about missing Linux dependencies Some extensions rely on libraries not found in the certain Docker images. See the Containers article for a few options on resolving this issue. Speeding up containers in Docker Desktop By default, Docker Desktop only gives containers a fraction of your machine capacity. In most cases, this is enough, but if you are doing something that requires more capacity, you can increase memory, CPU, or disk use.

First, try stopping any running containers you are no longer using. If this doesn't solve your problem, you may want to see if CPU usage is actually the issue or if there is something else going on. An easy way to check this is to install t

The rest of this page is on the live site.