Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist state and local keys across devcontainer rebuilds in VSCode #40

Closed
maxlyth opened this issue Jul 26, 2024 · 2 comments
Closed

Comments

@maxlyth
Copy link

maxlyth commented Jul 26, 2024

This devcontainer feature stores the Tailscale state in /workspaces/.tailscale/ but that is outside the structure that is automatically mapped by VSCode to the local project directory so the state was lost each time the container is rebuilt.

I have a few other states that I need to persist across container rebuilds such as shell history and authkeys for CLI tools such as Supabase and Doppler. My solution is to bind mount these to a .devcontainer/volumes/ folder.

You can also use Docker Volumes but these are opaque, easy to loose, and I prefer to keep all config relating to a project together. You probably want to add the volumes directory to .gitignore as there are likely privileged keys stored in there and each project contributor keeps their own separate keys.

To setup, once Tailscale is connected, inside the devcontainer run:
mkdir .devcontainer/volumes && sudo cp -r /workspaces/.tailscale .devcontainer/volumes

and then add the following to the mounts section of devcontainer.json
"source=${localWorkspaceFolder}/.devcontainer/volumes/.tailscale,target=/workspaces/.tailscale,type=bind"

If someone knows a better way to do this then please chime in.

@raggi
Copy link
Member

raggi commented Mar 12, 2025

Are devcontainers unique, in other words would this state ever end up being shared by more than one devcontainer instance?

raggi added a commit that referenced this issue Mar 13, 2025
The state directory is now in the default location inside the container,
/var/lib/tailscale and other default parameters for tailscaled are
removed. The state directory is now a mount declared in the feature
specification, and references `${devcontainerId}` so that the state is
local to the particular devcontainer instance.

Updates #40
raggi added a commit that referenced this issue Mar 13, 2025
The state directory is now in the default location inside the container,
/var/lib/tailscale and other default parameters for tailscaled are
removed. The state directory is now a mount declared in the feature
specification, and references `${devcontainerId}` so that the state is
local to the particular devcontainer instance.

Updates #40
raggi added a commit that referenced this issue Mar 13, 2025
The state directory is now in the default location inside the container,
/var/lib/tailscale and other default parameters for tailscaled are
removed. The state directory is now a mount declared in the feature
specification, and references `${devcontainerId}` so that the state is
local to the particular devcontainer instance.

Updates #40
raggi added a commit that referenced this issue Mar 13, 2025
The state directory is now in the default location inside the container,
/var/lib/tailscale and other default parameters for tailscaled are
removed. The state directory is now a mount declared in the feature
specification, and references `${devcontainerId}` so that the state is
local to the particular devcontainer instance.

Updates #40
@raggi
Copy link
Member

raggi commented Mar 13, 2025

With the patches landed in main this should be addressed. Tag should happen later this week.

@raggi raggi closed this as completed Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants