dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Bug: Critical issue with environment variables

Open axellpadilla opened this issue 5 months ago • 6 comments

To Reproduce

When creating some special chars and combinations in the environment variables windows, when using compose, some are not preserved. Try using $ for example, or compare !"#$%&/()=? on the env variables ui vs final container values, you can end up with paword instead of pa$$word for example. I even have a situation where an inline json like THIS_JSON={"val":...{}} ends up like THIS_JSON={"val":...{}}} (Extra closing }).

Current vs. Expected behavior

Create critical tests for the env vars pipeline to warrant the values are preserved and pa$$word ends as pa$$word , including inline JSON, and make it comply.

Provide environment information

Ubuntu 24 server

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?

Both

Additional context

No response

Will you send a PR to fix it?

Maybe, need help

axellpadilla avatar Jun 23 '26 22:06 axellpadilla

I'm having the same problem using compose. I can't escape special characters from environment variables even when using quotes and backslashes.

I noticed that in the Dokploy frontend, the environment variable value is enclosed in quotes. However, inside the container, the same environment variable appears without the quotes, causing special characters to be interpreted. It seems the bug is likely in the way Dokploy generates the .env file.

Dokploy frontend: MAIL_PASSWORD="abc#de"

inside the container MAIL_PASSWORD=abc#de

Inside the application MAIL_PASSWORD=abc

Henriquex25 avatar Jul 02 '26 00:07 Henriquex25

@axellpadilla This explains a problem I've been chasing for a while. At first I assumed my Compose file or application was parsing the values incorrectly, but after comparing the generated environment inside the container, it looks like certain special characters aren't making it through intact.

I ended up deploying the same application on Kubeara to rule out my configuration, and values containing $, #, and inline JSON were preserved exactly as defined there.

dhaval-p-iqud avatar Jul 17 '26 10:07 dhaval-p-iqud

@dhaval-p-iqud , @Henriquex25 we had to use BASE64 a lot

axellpadilla avatar Jul 17 '26 23:07 axellpadilla

One thing worth trying: setting the timeout at the transport layer rather than the request level — avoids the race condition.

viktoriavikulya avatar Jul 17 '26 23:07 viktoriavikulya

Reproduced and confirmed on v0.29.13 — values are lost between the Environment tab and the running container. Two distinct failure modes, both real data loss.

Test: Compose service with env_file: .env, Environment tab containing exactly:

TESTPASS=pa$$word
TESTJSON={"val":{"a":1}}
TESTSPECIAL=!"#$%&/()=?

Generated .env on disk:

TESTPASS=pa$$word
TESTJSON={"val":{"a":1}}
TESTSPECIAL=!"

Actual environment inside the running container:

TESTPASS=pa$word
TESTJSON={"val":{"a":1}}
TESTSPECIAL=!"

1. $$ collapses to $ — your pa$$word case. The value survives to .env intact, but Docker Compose performs $$ → $ interpolation when reading it, so the container gets pa$word. Anything written with a literal $$ is silently altered.

2. Everything from # onward is dropped — !"#$%&/()=? becomes !", already truncated in the .env file itself, because # starts a comment in dotenv syntax and the value is written unquoted.

Inline JSON without $ or # round-tripped correctly in my run, so the extra } you saw is likely a downstream effect of one of the two above rather than a third bug — if you still have that exact value, please paste it and I'll re-test it verbatim.

Confirmed; keeping open. The fix needs proper quoting/escaping when serializing values into .env.

Siumauricio avatar Aug 04 '26 20:08 Siumauricio

@Siumauricio is this but it fails only one server, son can't repro precisely

SSO_CONFIG_DICT={"version":2,"providers":{"provider1":{"type":"oidc","provider_name":"provider","client_id":"7897941234987421354","secret":"ALongSecretWIthoutSpecialChars2310","server_url":"https://web.example.com","allowed_email_domains":[]}}}

Tried all different ways, what worked, removing one last } so the added one makes it right.

axellpadilla avatar Aug 05 '26 03:08 axellpadilla