dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Dokploy displaying registry password in server logs (also sent in emails for build failures)

Open nktnet1 opened this issue 5 months ago • 7 comments

To Reproduce

  1. Configure a registry
  2. Deploy an application with rollback configured
  3. Observe that your registry password is visible in plain text in Dokploy's server logs

See image further below for details.

Current vs. Expected behavior

The password should not be visible in plain text in the server logs.

If email notifications is configured for build failures, the password will also appear in the email.

Provide environment information

Not relevant

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

Application

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

Same server where Dokploy is installed

Additional context

Example:

dokploy-leaking-registry-password-in-plain-text

  

As an aside, printing the full commands makes the logs look quite confusing - it looks like there are errors present, when in reality it's just the tail-end of the command itself containing error-handling logic.

Will you send a PR to fix it?

Maybe, need help

nktnet1 avatar Jun 23 '26 22:06 nktnet1

I traced this issue through the codebase. The root cause is in the getRegistryCommands function in packages/server/src/utils/cluster/upload.ts. This function generates the docker login command using safeDockerLoginCommand and embeds it directly into a shell script that gets executed with its stdout/stderr redirected to the deployment log file [1]:

(${command}) >> ${deployment.logPath} 2>&1

The safeDockerLoginCommand generates a command like:

printf %s 'YOUR_PASSWORD' | docker login 'registry.example.com' -u 'username' --password-stdin

While --password-stdin correctly avoids passing the password as a CLI argument (which would show in ps), the printf %s 'YOUR_PASSWORD' portion is part of the command string itself. When this command is logged or if the shell has set -x enabled, the password becomes visible in the deployment log file, which is then streamed to the UI via WebSocket [2].

A potential fix would be to suppress the login command output from the deployment logs. For example, in getRegistryCommands [3], you could redirect the login command's output to /dev/null and/or wrap it so the command itself isn't echoed:

const getRegistryCommands = (
  registry: Registry,
  imageName: string,
  registryTag: string,
): string => {
  const loginCmd = safeDockerLoginCommand(
    registry.registryUrl,
    registry.username,
    registry.password,
  );
  return `
echo "📦 [Enabled Registry] Uploading image to '${registry.registryType}' | '${registryTag}'" ;
{ ${loginCmd} ; } > /dev/null 2>&1 || {
    echo "❌ Registry Login Failed" ;
    exit 1;
}
echo "✅ Registry Login Success" ;
...
`;
};

This would suppress any output (including potential traces) from the login command while still catching failures. If you'd also like to handle cases where set -x is active further up the script chain, wrapping with { set +x; ${loginCmd}; set -x; } > /dev/null 2>&1 would be more robust.

Would you like me to look into any other places where credentials might leak, or help further with the fix?

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about dokploy Share Dosu with your team

dosubot[bot] avatar Jun 23 '26 22:06 dosubot[bot]

As an aside, for anyone getting the Unknown Blob error in their application deployment logs, e.g.

unknown blob
❌ Error pushing image
Error occurred ❌, check the logs for details.

I was able to fix it by setting REGISTRY_HTTP_RELATIVEURLS=true for the registry container - source:

  • https://community.traefik.io/t/docker-registry-pushing-behind-traefik-is-failing/5025/2

The full docker compose file I used for the registry is:

services:
  registry:
    image: registry:3
    environment:
      - USERNAME=${REGISTRY_USERNAME}
      - PASSWORD=${REGISTRY_PASSWORD}
      - REGISTRY_AUTH=htpasswd
      - REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm
      - REGISTRY_AUTH_HTPASSWD_PATH=/auth/registry.password
      - REGISTRY_HTTP_RELATIVEURLS=true
    entrypoint: ["sh", "/entrypoint.sh"]
    volumes:
      - registry-data:/var/lib/registry
      - type: bind
        source: ../files/entrypoint.sh
        target: /entrypoint.sh
      - type: bind
        source: ../files/config.yml
        target: /etc/docker/registry/config.yml
    healthcheck:
      test:
        - CMD
        - wget
        - "-q"
        - "--spider"     
        - "http://localhost:5000/"  
      interval: 5s
      timeout: 20s
      retries: 10

volumes:
  registry-data:

with the volume mounts copied from Coolify registry compose, i.e.

entrypoint.sh:

#!/usr/bin/env sh

set -e 

if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
    echo "Error: USERNAME and PASSWORD environment variables must be set"
    exit 1
fi

apk add --no-cache apache2-utils
mkdir -p "$(dirname "$REGISTRY_AUTH_HTPASSWD_PATH")"
chmod 755 "$(dirname "$REGISTRY_AUTH_HTPASSWD_PATH")"
htpasswd -Bbc "$REGISTRY_AUTH_HTPASSWD_PATH" "$USERNAME" "$PASSWORD"
registry serve /etc/docker/registry/config.yml

config.yml:

version: 0.1

log:
  fields:
    service: registry
storage:
  cache:
    blobdescriptor: inmemory
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  headers:
    X-Content-Type-Options: [nosniff]
health:
  storagedriver:
    enabled: true
    interval: 10s
    threshold: 3

nktnet1 avatar Jun 23 '26 23:06 nktnet1

Hello @nktnet1, any progress on this? Let me know if you need any help fixing it.

imrja8 avatar Jul 07 '26 18:07 imrja8

Hello @nktnet1, any progress on this? Let me know if you need any help fixing it.

@imrja8 feel free to submit a PR :).

nktnet1 avatar Jul 07 '26 20:07 nktnet1

Hmm, noted. I'm currently working on a few issues I had already looked into. Once I finish those, I'll get back to this one.

imrja8 avatar Jul 08 '26 04:07 imrja8

Opened a PR: #5068 . @imrja8 happy to defer if you'd started.

Souvik-Cyclic avatar Aug 12 '26 19:08 Souvik-Cyclic

Opened a PR: #5068 . @imrja8 happy to defer if you'd started.

@Souvik-Cyclic No worries, let’s keep yours. I was working on it locally but hadn’t opened a PR yet.

imrja8 avatar Sep 01 '26 13:09 imrja8