Skip to content

feat: OHE-3654: optional OH_PERSISTENCE_DIR to keep Compose data across down - #898

Merged
jlav merged 5 commits into
mainfrom
feat/compose-persistence-dir
Oct 21, 2026
Merged

jlav merged 5 commits into
mainfrom
feat/compose-persistence-dir

Conversation

@tofarr

@tofarr tofarr commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

HUMAN:

  • A human has tested these changes.

AGENT:


Why

After docker compose down and up, the Compose stack loses all users, settings and conversations, because the database, app file store and automation files were deliberately left unmounted (OHE-3376). Persistence should be the default, and named volumes are the native Compose way to get it: data survives down and is removed only by down -v.

This turns on named volumes db-data, app-filestore and automation-data, replacing the automation service's tmpfs. The automation image has no /data directory, so a new volume is root-owned and its service user (uid 42420) cannot write to it. The service therefore starts as root, runs chown on /data, and then drops to uid 42420 with setpriv before running alembic and uvicorn.

Summary

  • Mount named volumes for Postgres, the app file store and the automation service, and declare them at the top level of docker-compose.yml.
  • Replace the automation tmpfs with a volume, chowned to the service user at startup.
  • Update the compose header and README.md: data persists, docker compose down -v resets it, and changing DB_USER/DB_PASS after the first start needs a reset.

Issue Number

None. Tracked in Linear as OHE-3654.

How to Test

  1. docker compose up -d db automation-server, write a row to Postgres and a file to /data in the automation container, then docker compose down and up -d again: both are still there.
  2. docker compose down -v removes all three volumes.

I ran both with only db and automation-server; the full stack, including the app mount at /.openhands, was not run and was checked only through docker compose config. I did not confirm that uvicorn runs as uid 42420, because the image has no ps; the service did report healthy.

Video/Screenshots

N/A (compose configuration change).

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

Behaviour change: a stack that was previously wiped by docker compose down now keeps its data until down -v. Existing users upgrading from an older checkout keep the anonymous volumes Postgres created earlier, but those are not reused.

This PR was drafted by an AI agent on behalf of the user.


Enterprise server image for this PR:

ghcr.io/openhands/enterprise-server:sha-8f0d4ad

…ss down

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions github-actions Bot added the type: feat A new feature label Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

This PR does not seem to contain any modification to coverable code.

@tofarr
tofarr marked this pull request as ready for review October 20, 2026 14:31

@hieptl hieptl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🙏

@jlav jlav left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not just use a named volume? That solves for persisting data after docker compose down, with forced removal after docker compose down -v

For example:

automation-server:
    volumes:
      - automation-data:/data

Persistence should be opt-in rather than a change to that default.

I don't think that's the right call here. Persistence should be the default, and we have a familiar native way to accomplish that in docker compose which provides persistence and easy cleanup when persistence isn't desired.

Comment thread docker-compose.yml Outdated
Comment on lines +257 to +258
chown 42420:999 /data
exec setpriv --reuid 42420 --regid 999 --clear-groups sh -c 'alembic upgrade head && exec uvicorn openhands.automation.app:app --host 0.0.0.0 --port 8000'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make a follow up fix to the automation docker image so that this permission manipulation isn't necessary, but not blocking this PR over it.

@jlav
jlav enabled auto-merge (squash) October 21, 2026 17:37
@jlav
jlav merged commit d20518b into main Oct 21, 2026
17 of 18 checks passed
@jlav
jlav deleted the feat/compose-persistence-dir branch October 21, 2026 18:45
@jlav jlav mentioned this pull request Oct 21, 2026
1 of 6 tasks
@openhands-release-bot openhands-release-bot Bot added the released: 1.76.0 Shipped in 1.76.0 label Oct 22, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.76.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.76.0 Shipped in 1.76.0 type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants