You open a remote container in VS Code, start typing, and see no suggestions from GitHub Copilot. The Copilot icon in the status bar shows a line through it or remains gray. This happens because Copilot does not automatically authenticate or install inside the container environment. The root cause is that Copilot runs as a VS Code extension, and when you attach to a container, the extension must be explicitly configured to load inside that container. This article explains why Copilot fails in containers and provides the exact configuration steps to make it work.
Key Takeaways: Making GitHub Copilot Work in Dev Containers
- VS Code Remote > Containers extension: Must be installed on the host before opening any container.
- Dev container configuration file (devcontainer.json): The
extensionsproperty must includeGitHub.copilotandGitHub.copilot-chat. - Copilot status bar icon: Shows a line through the icon when Copilot is disabled in the container; clicking it reveals the configuration issue.
Why Copilot Stops Working Inside Containers
VS Code Remote Containers allow you to develop inside a Docker container that contains all the tools and dependencies your project needs. When you attach VS Code to a container, the editor runs on your host machine, but extensions must be installed inside the container to function. GitHub Copilot is a VS Code extension that requires authentication with your GitHub account. If the extension is not installed in the container, Copilot cannot start. Additionally, the extension must be granted the necessary permissions to access the file system and network inside the container. By default, VS Code does not copy extensions from the host to the container. You must explicitly list Copilot in the container configuration.
The authentication token for Copilot is stored on the host machine. When the extension loads inside the container, it must be able to read that token. If the token is not forwarded, Copilot will show as disabled. This is a security design: tokens are not automatically shared across environments.
How the Container Extension System Works
VS Code uses a devcontainer.json file to define the container environment. This file lives in the .devcontainer folder at the root of your project. When you reopen the folder in a container, VS Code reads this file and builds or attaches to a container with the specified settings. Extensions are listed under the extensions property as an array of extension IDs. If Copilot is not listed, it will not be installed. The same applies to Copilot Chat.
Steps to Enable GitHub Copilot in VS Code Containers
Follow these steps to configure Copilot inside a dev container. You need a project with an existing .devcontainer/devcontainer.json file. If you do not have one, create the .devcontainer folder and the devcontainer.json file manually.
- Open the devcontainer.json file
Navigate to the.devcontainerfolder in your project and opendevcontainer.jsonin VS Code. - Add the Copilot extension ID to the extensions array
Inside theextensionsarray, addGitHub.copilot. If you also want Copilot Chat, addGitHub.copilot-chat. The array should look like this:"extensions": ["GitHub.copilot", "GitHub.copilot-chat"]. Save the file. - Rebuild the container
Press F1 to open the Command Palette. Type Remote-Containers: Rebuild Container and select it. VS Code rebuilds the container with the new extensions installed. - Verify Copilot is active
After the container rebuilds, check the Copilot icon in the status bar at the bottom of the VS Code window. It should show a checkmark or the Copilot logo. If it shows a line through it, click the icon and select Sign In to GitHub to authenticate. - Authenticate Copilot inside the container
If prompted, complete the GitHub authentication flow in your browser. VS Code forwards the token to the container automatically after sign-in.
After these steps, Copilot should provide code suggestions as you type inside the container. Test by writing a function name or variable declaration.
If Copilot Still Has Issues in the Container
Copilot icon shows a line through it after rebuild
This indicates the extension is installed but not authenticated. Click the Copilot icon in the status bar. Select Sign In to GitHub. Complete the browser authentication. If the browser does not open, check that your VS Code settings allow remote authentication. You can also manually trigger the login by running the command GitHub Copilot: Sign In from the Command Palette.
Copilot suggestions appear but are generic or incorrect
This can happen if the container does not have the language server or SDK for the language you are using. Copilot relies on contextual clues from the file type and project structure. Install the relevant VS Code extensions for your language inside the container by adding their IDs to the extensions array in devcontainer.json. For example, add ms-python.python for Python or dbaeumer.vscode-eslint for JavaScript.
Copilot works on the host but not in the container
Verify that the extensions array in devcontainer.json includes GitHub.copilot. If the array is empty or missing, Copilot will not install. Also check that the container image includes the necessary network access to reach the Copilot API. Corporate firewalls or proxy settings can block Copilot. Configure HTTP_PROXY and HTTPS_PROXY environment variables in devcontainer.json if needed.
| Item | Host Environment | Container Environment |
|---|---|---|
| Description | Extensions run on the local machine with direct access to host files and network | Extensions run inside the container with isolated file system and network |
| Copilot extension install | Automatic when installed globally in VS Code | Must be listed in devcontainer.json extensions array |
| Authentication token | Stored locally and reused | Must be forwarded via VS Code Remote tunnel; may require manual sign-in |
| Network access to Copilot API | Uses host network directly | Uses container network; may need proxy settings |
| Configuration file | VS Code settings.json | devcontainer.json in .devcontainer folder |
Now you can configure GitHub Copilot inside any VS Code dev container. Start by checking your devcontainer.json file for the extensions property. If you frequently work with containers, consider creating a base devcontainer.json template that includes Copilot and your common language extensions. For advanced setups, you can use the remoteEnv property in devcontainer.json to set proxy variables and ensure Copilot can reach the API through corporate networks.