How to customize a GitHub Codespace with devcontainers and dotfiles
In GitHub Codespaces (verified 2026-10-24), add a .devcontainer/devcontainer.json (and optional Dockerfile) so every codespace installs the right extensions, ports and packages. Link a dotfiles repository under Codespaces settings for personal shell config, and store tokens in Codespaces secrets. Use VS Code Settings Sync in the codespace browser/desktop editor for UI preferences.
This goes beyond opening a basic codespace — focus is reproducible project config plus personalization. Org policies can block custom images or secrets.
Applies to GitHub.com Codespaces with a plan that includes compute. Dev containers follow the open devcontainer spec used by VS Code too.
Add a dev container and personalize your account
Define the project container
- In the repo, add
.devcontainer/devcontainer.json(VS Code: Command Palette → Dev Containers: Add Dev Container Configuration Files…). - Declare image/features,
customizations.vscode.extensions,forwardPortsandpostCreateCommandas needed. - Commit and open a new codespace so it rebuilds from the config.
Personalize your user
- GitHub → Settings → Codespaces → set a Dotfiles repository and enable automatic install.
- Add Codespaces secrets for tokens your setup scripts need (never commit secrets).
- In the editor, sign into Settings Sync if you want keybindings/theme everywhere.
Rebuild when things drift
- Command Palette → Codespaces: Rebuild Container after editing devcontainer.json.
- Pin machine type/region in Codespaces settings for cost/latency.
- Stop unused codespaces so they do not keep billing.
Our take: put team tools in devcontainer, put taste in dotfiles
Nobody wants your vim colors forced on CI — keep personal shell aliases out of the repo image.
If it fails
- Rebuild errors: invalid JSON or base image pull blocked — read the creation log.
- Dotfiles did nothing: repo privacy/permissions or install script exit code — check Codespaces settings.
- Secret missing in shell: name must match what your script reads; restart codespace after adding secrets.
- Org blocks Codespaces: ask an admin for policy exceptions.
Frequently asked questions
What is advanced Codespaces setup?
Project-level dev containers plus account dotfiles, secrets and editor sync so environments are repeatable.
What is devcontainer.json?
A config file that describes the container image, tools, extensions and setup commands for the codespace.
What are Codespaces dotfiles?
A GitHub repo GitHub can clone into each codespace to install your personal shell/editor config.
When should I rebuild the container?
After changing .devcontainer files, or when packages inside the VM are badly broken.
Is this the same as local Dev Containers?
Same spec idea — Codespaces runs it in the cloud on GitHub’s VMs.