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 connectedcode .Run in a WSL terminal to open that folder in VS Code connected to WSLWSL: Connect to WSLCommand Palette: open a window running inside your default WSL distributionWSL: Open Folder in WSL…Choose a folder inside WSL to openWSL: Reopen Folder in WSL / in WindowsSwitch the current folder between WSL and WindowsDev Containers: Reopen in ContainerReopen the folder inside a container built from its dev container filesDev Containers: Reopen Folder LocallyLeave the container and go back to a normal windowExtensions run where you connectSome install in the remote side: look for Install in WSL / Container on an extensionWSL Settings (remote.WSL.*)
remote.WSL.fileWatcher.pollingPoll for file changes instead of using notifications (default false); try it if changes are missedremote.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 connectdevcontainer.json (the file)
.devcontainer/devcontainer.jsonWhere the container definition lives (also allowed: .devcontainer.json in the folder root)nameThe label shown for the containerimageA ready-made image to use, e.g. mcr.microsoft.com/devcontainers/python:3build.dockerfileBuild from your own Dockerfile instead of using imagedockerComposeFile / serviceUse a Compose file and say which service is your workspacefeaturesAdd ready-made tools (Node, Git, Docker CLI…) to the containerforwardPortsPorts to forward to your machine, e.g. [8000]postCreateCommandA command run once after the container is created, e.g. pip install -r requirements.txtcustomizations.vscode.extensionsExtensions installed automatically inside the containercustomizations.vscode.settingsSettings applied inside the containerremoteUserThe user VS Code runs as inside the containercontainerEnv / mounts / runArgsEnvironment variables, extra mounts and extra docker run optionsDev Containers Commands
Dev Containers: Add Dev Container Configuration Files…Create a .devcontainer folder from a templateDev Containers: Rebuild ContainerRebuild after you change devcontainer.json or the DockerfileDev Containers: Rebuild Without Cache and Reopen in ContainerA clean rebuild when something is stuckDev Containers: Attach to Running Container…Open VS Code inside a container that is already runningDev Containers: Open Folder in Container…Pick a folder and open it in a containerDev 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 outputDev Containers: Clean Up Dev Containers…Remove old dev containersDev Containers: Configure Container Features…Add tools to the container from a listDev Containers: Try a Dev Container Sample…Open a ready-made sample project in a containerDev 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 updev.containers.cacheVolumeUse a volume to speed up repeated builds (default true)dev.containers.gpuAvailabilitydetect (default), all, none: pass GPUs to the containerdev.containers.executeInWSL / executeInWSLDistroRun Docker through WSL instead of Windows (default false)dev.containers.logLeveldebug (default), info, tracedotfiles.repository / dotfiles.installCommandA Git repository of your dotfiles, cloned into each container, and the command that installs themdotfiles.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 portsremote.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 portsremote.portsAttributesPer-port options, e.g. { "8000": { "label": "FastAPI", "onAutoForward": "openBrowser" } }onAutoForward valuesnotify, openBrowser, openBrowserOnce, openPreview, silent, ignoreremote.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 moreExtensions & the Remote Side
remote.extensionKindForce an extension to run on the UI (local) or workspace (remote) sideremote.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 connectedDisable (Workspace)Turn an extension off for just this remote folderContainers (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 optionsdocker.languageserver.diagnostics.*Dockerfile checks, each ignore, warning (default) or errorA 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 logSlow 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.