How to mount a Codespace's workspace in a Docker container

Thought I’d share this here, since it might help others (feedback welcome):

Use --volumes-from to remount the volumes for the Codespace (e.g. /workspaces/myrepo) inside the container you are starting. This requires knowing the container ID of the container in which the Codespace is running, which we can obtain with docker ps --filter "label=Type=codespaces".

As a bonus --workdir can also be used to start the container in the current directory.

Putting it together:

$ docker run -it --rm --volumes-from $(docker ps --filter "label=Type=codespaces" -q) --workdir $(pwd) alpine:latest

/workspaces/myrepo/ # ls .
[list of files]