VS Code Remote and Containers Cheat Sheet

Sidebar

Programming · VS Code Remote and Containers Cheat Sheet

Working inside WSL, dev containers and other remote environments: the settings to search for, the commands, the devcontainer.json file and port forwarding. Sheet 14 in the VS Code series. Checked against the WSL (0.104.3), Dev Containers (0.469.0) and Containers (2.5.2) extensions installed on this machine; Remote-SSH and Remote Tunnels are separate extensions and are not covered.

Working Remotely: The Basics

Remote indicator (bottom-left)The green button in the status bar: click it for the remote menu, or to see where you are connected
code .Run in a WSL terminal to open that folder in VS Code connected to WSL
WSL: Connect to WSLCommand Palette: open a window running inside your default WSL distribution
WSL: Open Folder in WSL…Choose a folder inside WSL to open
WSL: Reopen Folder in WSL / in WindowsSwitch the current folder between WSL and Windows
Dev Containers: Reopen in ContainerReopen the folder inside a container built from its dev container files
Dev Containers: Reopen Folder LocallyLeave the container and go back to a normal window
Extensions run where you connectSome install in the remote side: look for Install in WSL / Container on an extension

WSL Settings (remote.WSL.*)

remote.WSL.fileWatcher.pollingPoll for file changes instead of using notifications (default false); try it if changes are missed
remote.WSL.fileWatcher.pollingIntervalMilliseconds between polls (default 5000)
remote.WSL.useShellEnvironmentUse your shell's environment for the VS Code server (default true)
remote.WSL.downloadInBackgroundDownload the VS Code server in the background (default true)
remote.WSL.debugExtra logging for connection problems (default false)
remote.WSL1.connectionMethod / remote.WSL2.connectionMethodChoose how VS Code connects (default empty: automatic)
terminal.integrated.useWslProfilesList WSL distributions as terminal profiles (default true)
WSL: Show LogCommand Palette: open the log when WSL will not connect

devcontainer.json (the file)

.devcontainer/devcontainer.jsonWhere the container definition lives (also allowed: .devcontainer.json in the folder root)
nameThe label shown for the container
imageA ready-made image to use, e.g. mcr.microsoft.com/devcontainers/python:3
build.dockerfileBuild from your own Dockerfile instead of using image
dockerComposeFile / serviceUse a Compose file and say which service is your workspace
featuresAdd ready-made tools (Node, Git, Docker CLI…) to the container
forwardPortsPorts to forward to your machine, e.g. [8000]
postCreateCommandA command run once after the container is created, e.g. pip install -r requirements.txt
customizations.vscode.extensionsExtensions installed automatically inside the container
customizations.vscode.settingsSettings applied inside the container
remoteUserThe user VS Code runs as inside the container
containerEnv / mounts / runArgsEnvironment variables, extra mounts and extra docker run options

Dev Containers Commands

Dev Containers: Add Dev Container Configuration Files…Create a .devcontainer folder from a template
Dev Containers: Rebuild ContainerRebuild after you change devcontainer.json or the Dockerfile
Dev Containers: Rebuild Without Cache and Reopen in ContainerA clean rebuild when something is stuck
Dev Containers: Attach to Running Container…Open VS Code inside a container that is already running
Dev Containers: Open Folder in Container…Pick a folder and open it in a container
Dev Containers: Clone Repository in Container Volume…Clone into a Docker volume (faster file access than a mounted folder)
Dev Containers: Show Container LogRead the build and start-up output
Dev Containers: Clean Up Dev Containers…Remove old dev containers
Dev Containers: Configure Container Features…Add tools to the container from a list
Dev Containers: Try a Dev Container Sample…Open a ready-made sample project in a container

Dev Containers Settings (dev.containers.*)

dev.containers.defaultExtensionsExtension IDs installed in every dev container (default [])
dev.containers.defaultFeaturesDev container features added to every container (default {})
dev.containers.dockerPathThe Docker program to run (default docker)
dev.containers.dockerComposePathThe Compose program to run (default docker-compose)
dev.containers.workspaceMountConsistencycached (default), consistent, delegated: file sharing mode (mostly macOS)
dev.containers.copyGitConfigCopy your Git name and email into the container (default true)
dev.containers.gitCredentialHelperConfigLocationglobal (default), system, none: where the Git credential helper is set up
dev.containers.cacheVolumeUse a volume to speed up repeated builds (default true)
dev.containers.gpuAvailabilitydetect (default), all, none: pass GPUs to the container
dev.containers.executeInWSL / executeInWSLDistroRun Docker through WSL instead of Windows (default false)
dev.containers.logLeveldebug (default), info, trace
dotfiles.repository / dotfiles.installCommandA Git repository of your dotfiles, cloned into each container, and the command that installs them
dotfiles.targetPathWhere the dotfiles go inside the container (default ~/dotfiles)

Ports (remote.*)

remote.autoForwardPortsForward ports when a program starts listening on them (default true)
remote.autoForwardPortsSourceprocess (default), output, hybrid: how VS Code detects new ports
remote.forwardOnOpenForward a port when you open its URL (default true)
remote.restoreForwardedPortsRe-create forwarded ports after a reload (default true)
remote.localPortHostlocalhost (default) or allInterfaces: who on your network can reach forwarded ports
remote.portsAttributesPer-port options, e.g. { "8000": { "label": "FastAPI", "onAutoForward": "openBrowser" } }
onAutoForward valuesnotify, openBrowser, openBrowserOnce, openPreview, silent, ignore
remote.otherPortsAttributesOptions for every port not listed in remote.portsAttributes (default notify)
Ports viewPanel tab listing forwarded ports, with an address to click and a button to forward more

Extensions & the Remote Side

remote.extensionKindForce an extension to run on the UI (local) or workspace (remote) side
remote.downloadExtensionsLocallyDownload extensions on your machine and send them across (default false)
remote.serverDownloadBaseUrlWhere the VS Code server is downloaded from (default the standard update site)
Install in WSL / ContainerButton on an extension in the Extensions view when connected
Disable (Workspace)Turn an extension off for just this remote folder

Containers (Docker) Extension

containers.containerClientWhich engine to use: Docker, Podman, nerdctl, Finch (default: automatic)
containers.containerCommand / composeCommandOverride the program names (default empty: automatic)
containers.containers.groupByHow the Containers view groups items (default Compose Project Name)
containers.containers.label / sortByLabel (default FullTag) and sort order (default CreatedTime)
containers.images.groupBy / labelImages grouped by Repository and labelled by Tag (defaults)
containers.images.checkForOutdatedImagesMark images that have a newer version online (default true)
containers.composeBuild / composeDetachedCompose Up builds first / runs in the background (both default true)
containers.promptForRegistryWhenPushingImagesAsk which registry to push to (default true)
containers.showRemoteWorkspaceWarningWarn when you start containers from a remote workspace (default true)
containers.commands.build / run / attach / logsTemplates for the commands the extension runs; edit to add your own options
docker.languageserver.diagnostics.*Dockerfile checks, each ignore, warning (default) or error

A Reasonable Starter Set (my suggestions, not defaults)

Keep projects inside WSLUnder /home/you/…, not /mnt/c/…: much faster file access
"dev.containers.defaultExtensions": ["ms-python.python"]Python tooling in every dev container (use your own list)
"remote.portsAttributes": { "8000": { "label": "API" } }A friendly name for the port your server uses
"remote.WSL.fileWatcher.polling": trueOnly if file changes in WSL are not noticed
"dev.containers.logLevel": "info"Less noise in the container log
Slow or missing file changes in WSL? Check where the files live
A project stored on the Windows drive (under /mnt/c) is much slower to read from inside WSL than one stored in the Linux file system (under /home), and file change notifications across that boundary are less reliable. Keep the project in the WSL file system when you work from WSL; only if changes are still missed, turn on remote.WSL.fileWatcher.polling.
Container changes didn't apply? Rebuild
Editing devcontainer.json or the Dockerfile does nothing to a running container. Run Dev Containers: Rebuild Container, or Rebuild Without Cache and Reopen in Container if the old layers keep being reused. Anything you installed by hand inside the container disappears on rebuild, so put it in postCreateCommand or features.