Cursor chat persistence across container sessions

Hello,

I am running Cursor by connecting via a docker container, however after ending the session I am losing my Cursor chats. I am looking for a way to keep the chats and workspaces persistent even after a session is closed and the container is stopped.

How can I achieve this?

Hey, thanks for the report. Losing chat history when you stop a Docker container is expected behavior, since the data is stored inside the container and gets removed with it.

Cursor chat history is stored in workspaceStorage (the state.vscdb files). To keep history between sessions:

  1. Use a Docker volume to persist Cursor data:

    • Mount ~/.cursor-server from the container to the host
    • Example: -v cursor-data:/home/user/.cursor-server
  2. If you’re using a devcontainer, add this to devcontainer.json:

    "mounts": [
      "source=cursor-profile,target=/home/vscode/.cursor-server,type=volume"
    ]
    
  3. Consider using the Dev Containers extension from Anysphere. It’s better integrated with Cursor.

Quick question: are you using devcontainer.json, or are you just attaching to the container? That’ll help me give more specific recommendations.

Hi, Dean, thanks.

I am attaching to the container but I also think I have a devcontainer.json file. I already have the Dev Containers extension.

Thanks for the info.

I can see you’re using “Attach to Container” (based on nameConfigs). In that case, Cursor server data is stored inside the container and gets deleted with it.

To make chat history persistent:

  1. Add a volume for cursor-server data when starting the container:
    docker run -v cursor-server-data:/home/jovyan/.cursor-server ...

  2. If you want to use devcontainer.json instead of attach, add a mount:

"mounts": [
  "source=cursor-profile,target=/home/jovyan/.cursor-server,type=volume"
]
  1. Make sure remoteUser in the config matches the user inside the container (in your case, jovyan).

Quick check: do you create a new container each time, or reuse the same one? If the container gets recreated, a volume is required to keep the history.

The problem is I have no control over the creation of this container, it is an app that is launching it.

I can’t add a mount like you are doing. But, there is a mount available that I can use (I can not add new ones)

And the container is also deleted when the app is closed, so I am unable to reuse it.

I think I could solve this by doing a symlink from .cursor-server to the automatically mounted directory, but that didn’t work either.

Chats are stored by the container name and workspace path – specifically the workspace uri – on your client device (not inside the container). Are you able to deterministically control the container name so it is consistent across sessions?

I don’t think so, whenever this container is launched the number associated with it changes, I am able to re-open the chats if I close cursor without stopping the container though.