Skip to content

Environment variables from the UI are deployed with surrounding double quotes in Docker Swarm Compose stacks #5096

Closed

Description

@ThiagoCrepequer

To Reproduce

Create a Docker Compose project in Dokploy.

Configure a variable in the Environment tab:

QUARKUS_LOG_SENTRY_DSN=https://[email protected]/0000000000000000

Reference it in the Compose service:

services:
backend:
environment:
QUARKUS_LOG_SENTRY_DSN: ${QUARKUS_LOG_SENTRY_DSN:?QUARKUS_LOG_SENTRY_DSN is not defined}

Deploy the project as a Docker Swarm stack.

Inspect the failed Swarm task/container configuration.

Observe that the environment variable contains literal surrounding double quotes.

The generated Dokploy .env file also contains the quotes:

first=["] last=["] length=94

The expected unquoted value is:

first=[h] last=[4] length=92

The failed container task receives the same quoted value:

first=["] last=["] length=94

Current vs. Expected behavior

Expected behavior

The service should receive the exact value entered in the Environment tab, without additional quote characters:

QUARKUS_LOG_SENTRY_DSN=https://...

Characters inside the value, such as :, /, @, = and _, should be preserved without requiring users to add quotes manually.

Actual behavior

The deployed Docker Swarm service receives:

QUARKUS_LOG_SENTRY_DSN="https://..."

The quotes become part of the value and cause URL parsing to fail.

Provide environment information

Dokploy version: Version v0.30.0
Deployment type: Docker Compose / Docker Swarm
Compose deployment mode: Stack
Dokploy topology: Dokploy manager with remote production nodes
Application runtime: Quarkus / Java
Number of Swarm nodes: 2

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

Docker Compose

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

Remote server

Additional context

No response

Will you send a PR to fix it?

Maybe, need help

Activity

  1. linear-code commented on Aug 16, 2026

    @linear-code
  2. dosubot commented on Aug 16, 2026

    @dosubot

    Hi @ThiagoCrepequer! I'm Dosu and I'm helping the Dokploy team.

    I can pinpoint exactly where this double-quote issue originates in the codebase. The root cause is in how the .env file is generated for stack deployments.

    The .env file — prepareEnvironmentVariablesForFile

    In packages/server/src/utils/docker/utils.ts, every value written to the .env file is explicitly wrapped in double quotes:

    return `${key}="${escapedValue}"`;

    This is valid dotenv syntax — docker compose (non-stack mode) correctly strips those quotes when reading the file. However, docker stack deploy does not strip dotenv quotes during variable substitution, so the literal " characters become part of the value.

    How the .env file gets written for stack deploys

    The getCreateEnvFileCommand function calls prepareEnvironmentVariablesForFile and writes the result to disk. So your value https://examplePublicKey@... becomes "https://examplePublicKey@..." in the file. When docker stack deploy substitutes ${QUARKUS_LOG_SENTRY_DSN} from this .env file, the quotes are included as literal characters.

    Note that for stack deploys, Dokploy also inlines variables into the shell via env -i using getExportEnvCommand, which uses shell-quote for proper shell escaping. But docker stack deploy performs its own variable substitution from the .env file rather than the shell environment, so the double-quoted .env values are what actually get interpolated.

    Root cause summary: prepareEnvironmentVariablesForFile wraps all values in "..." for dotenv safety, which works for docker compose but breaks docker stack deploy because the latter treats quotes as literal value content.

    The fix would need prepareEnvironmentVariablesForFile to avoid wrapping values in double quotes when the target is a stack deployment (or use an escaping strategy that docker stack deploy handles correctly), while still escaping special characters like $ and #.

    This is closely related to #4694, where @Siumauricio confirmed the underlying issue and noted that the fix requires proper quoting/escaping when serializing values into .env [1].

    Workaround for now: You can try base64-encoding the value and decoding it at runtime in your application, as other users affected by #4694 have done.

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dokploy Share Dosu with your team

  3. JerresonJ commented on Aug 17, 2026

    @JerresonJ

    This is killing us… all our stacks are unmanageable now.
    Not only is .env getting quoted, but we’ve noticed stack compose health checks getting mangled too.

    Can we get a patch out soon as possible here.

  4. added a commit that references this issue on Aug 18, 2026
    d183018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions