Skip to content

Database Restore Fails with Custom Stack Names #3458

@Patrick3131

Description

@Patrick3131

To Reproduce

Database restore fails when:

  1. The database is deployed using a custom Docker stack name (not the auto-generated Dokploy stack name)

To Reproduce

  1. Deploy a PostgreSQL database using a custom Docker stack name:
    docker stack deploy -c postgres.docker-compose.yml -c postgres.docker-compose.external.yml my-postgres

Current vs. Expected behavior

Expected Behavior
Dokploy should successfully locate the PostgreSQL container regardless of the stack name used
Dokploy should detect the backup file format (.sql.gz = plain SQL, .dump or custom format = pg_restore) and use the appropriate tool
The restore should complete successfully

Actual Behavior
The restore command fails with "No such container: sh"
The container filter uses hardcoded labels that don't match custom stack names:
--filter "label=com.docker.stack.namespace=databases-app-oq9el4" --filter "label=com.docker.swarm.service.name=databases-app-oq9el4_postgres"
When the filter returns no containers, $CONTAINER_ID is empty, causing docker exec -i $CONTAINER_ID sh -c "..." to become docker exec -i sh -c "...", which fails

Provide environment information

Dokploy version 0.26.3

Which area(s) are affected? (Select all that apply)

Databases

Are you deploying the applications where Dokploy is installed or on a remote server?

Same server where Dokploy is installed

Additional context

No response

Will you send a PR to fix it?

No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions