You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Environment variables from the UI are deployed with surrounding double quotes in Docker Swarm Compose stacks #5096
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
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.
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.
Reacted by Michael V, Thiago Crepequer, chikenare, Jonathan and vincent-tarrit
Activity
linear-code commentedon Aug 16, 2026
DOK-645
dosubot commentedon Aug 16, 2026
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
.envfile is generated for stack deployments.The
.envfile —prepareEnvironmentVariablesForFileIn
packages/server/src/utils/docker/utils.ts, every value written to the.envfile is explicitly wrapped in double quotes:This is valid dotenv syntax —
docker compose(non-stack mode) correctly strips those quotes when reading the file. However,docker stack deploydoes not strip dotenv quotes during variable substitution, so the literal"characters become part of the value.How the
.envfile gets written for stack deploysThe
getCreateEnvFileCommandfunction callsprepareEnvironmentVariablesForFileand writes the result to disk. So your valuehttps://examplePublicKey@...becomes"https://examplePublicKey@..."in the file. Whendocker stack deploysubstitutes${QUARKUS_LOG_SENTRY_DSN}from this.envfile, the quotes are included as literal characters.Note that for stack deploys, Dokploy also inlines variables into the shell via
env -iusinggetExportEnvCommand, which usesshell-quotefor proper shell escaping. Butdocker stack deployperforms its own variable substitution from the.envfile rather than the shell environment, so the double-quoted.envvalues are what actually get interpolated.Root cause summary:
prepareEnvironmentVariablesForFilewraps all values in"..."for dotenv safety, which works fordocker composebut breaksdocker stack deploybecause the latter treats quotes as literal value content.The fix would need
prepareEnvironmentVariablesForFileto avoid wrapping values in double quotes when the target is a stack deployment (or use an escaping strategy thatdocker stack deployhandles 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.
test: assert Sentry DSN is emitted without surrounding quotes
JerresonJ commentedon Aug 17, 2026
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.
docker stack deploydoes not strip quotes) #5113 as a duplicate of this issuefix: don't quote .env values for stack deploys
chore(release): 0.42.0 [skip ci]