Setting default workspace in Docker Dev environment

Hi all, I’m new to Docker Dev Environments and I’m trying to set up a simple dev environment in a local folder on my Windows 10 desktop.

Windows 10 21H2, build 19044,2486
Docker Desktop for Windows 4.16.2
Visual Studio Code 1.70.2

In my local directory I’ve created a very basic compose-dev.yaml file:

services:
app:
entrypoint:
- sleep
- infinity
image:
init: true
volumes:
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
volumes:
- “./:/home/coder”

This is basically the default yaml that is created when you start with an empty local folder and build a dev environment. I’ve only modified it to pull our image and to mount my local folder to /home/coder.

If I build the dev environment without mounting the local folder, when I open it in vscode it creates a folder in the container named COM.DOCKER.DEVENVIRONMENTS.CODE and maps the local folder to that. This becomes the default workspace in vscode.

Instead, I want the workspace to be /home/coder. When I add that volume in compose-dev.yaml and build the environment, vscode does not create the COM.DOCKER.DEVENVIRONMENTS.CODE folder, but instead says “Workspace does not exist” and prompts me to select another folder. I browse to the folder I want to use, which is /home/coder, and it restarts the dev container successfully with my chosen folder now set as the workspace.

This gets me to where I want to be, but how can I instruct Docker/vscode to set the workspace to my preferred location at the time it is built so that I don’t have to go through the extra step of allowing it to fail, browsing to the folder I want, then waiting for it to be created again?

Any insight is appreciated!
Thanks, Jim

1 Like