Skip to content

feat: implement postgres password update and fix swarm container resolution#3368

Closed
JuansesDev wants to merge 1 commit intoDokploy:canaryfrom
JuansesDev:feat-update-postgres-db-password
Closed

feat: implement postgres password update and fix swarm container resolution#3368
JuansesDev wants to merge 1 commit intoDokploy:canaryfrom
JuansesDev:feat-update-postgres-db-password

Conversation

@JuansesDev
Copy link
Copy Markdown

Description:

This PR implements the ability to update the Postgres database password directly from the Dokploy Dashboard. It ensures that the password is synchronously updated in three places: the Docker container (via ALTER USER), the Dokploy internal database, and the environment variables of any dependent applications within the same organization.

Additionally, it includes a critical fix for Docker Swarm environments where docker exec commands were failing because they attempted to use the Service Name instead of the Container ID.

Changes:

  • Backend (packages/server/src/services/postgres.ts):

    • Added changePostgresPassword service function.
    • Implemented logic to dynamically resolve the Container ID from the Service Name (docker ps -q -f name=...) before executing commands, solving stability issues in Swarm.
    • Added logic to automatically update DATABASE_URL in dependent apps when the password changes.
    • Refactored execAsyncRemote calls to properly handle stdout.
  • API (apps/dokploy/server/api/routers/postgres.ts):

    • Added changePassword protected procedure to the postgres router.
  • Frontend (show-internal-postgres-credentials.tsx):

    • Added a secure "Edit" dialog for updating the password.
    • Cleaned up the UI logic.

Type of Change:

  • feat: A new feature (Postgres Password Update)
  • fix: A bug fix (Docker Swarm Container Resolution)
  • refactor: Code cleanup and linting fixes (Biome)

How Has This Been Tested?

  • Manual verification: Changed password via UI and verified connection strings in dependent apps.
  • Verified that docker exec commands successfully target the running container in a Swarm environment.
  • Verified that invalid inputs or container states return appropriate errors.

Checklist:

  • My code follows the code style of this project (Biome linting passed).
  • I have performed a self-review of my own code.
  • I have verified that new and existing unit tests pass locally with my changes.

@Siumauricio
Copy link
Copy Markdown
Contributor

Fixed here #4144

@Siumauricio Siumauricio closed this Apr 4, 2026
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

Successfully merging this pull request may close these issues.

2 participants