Skip to content

fix: run docker login before service update to distribute registry au…#4489

Draft
guizaodev wants to merge 1 commit into
Dokploy:canaryfrom
guizaodev:canary
Draft

fix: run docker login before service update to distribute registry au…#4489
guizaodev wants to merge 1 commit into
Dokploy:canaryfrom
guizaodev:canary

Conversation

@guizaodev
Copy link
Copy Markdown

What is this PR about?

Fixes Docker Swarm deployments where containers accumulate in "Starting" state and old containers are never replaced. When deploying applications to multi-node Swarm clusters, worker nodes cannot pull images from private registries (e.g., GHCR) because docker login is never executed on the daemon — only authconfig is passed through the Dockerode API. While authconfig is sent as the X-Registry-Auth header, Docker Swarm also requires the daemon's cached credentials (~/.docker/config.json) to distribute auth to worker nodes, as documented in Docker's --with-registry-auth behavior.
This PR adds a dockerLoginForApplication() call before service.update() / createService() in mechanizeDockerContainer, mirroring the pattern already used in rollbackApplication (rollbacks.ts:208-214), which includes an explicit comment acknowledging this limitation.

Checklist

Before submitting this PR, please make sure that:

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. If you have not tested it yet, please do so before submitting. This helps avoid wasting maintainers' time reviewing code that has not been verified by you.

Issues related (if applicable)

closes #4232
related #4411

…th to Swarm worker nodes

Docker Swarm requires credentials to be cached in the daemon's
~/.docker/config.json (via ) to properly distribute
them to worker nodes during service updates. The  passed
through Dockerode's API is sent as the X-Registry-Auth header, but
this alone is insufficient for Swarm credential distribution -- the
daemon must also have the credentials locally cached.

This mirrors the pattern already used in rollbacks.ts which includes
a comment acknowledging this limitation:

  'The authconfig in CreateServiceOptions alone is not sufficient --
   Docker Swarm also relies on the daemon's cached credentials
   (~/.docker/config.json) to distribute auth to nodes.'

Without this, deployments to multi-node Swarm clusters fail because
worker nodes cannot pull images from private registries, causing
containers to accumulate in 'Starting' state as old tasks are never
replaced (start-first strategy waits for new tasks to become healthy).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug report: "Deploy" on Dokploy Application - Swarm mode does not update running container, but "Stop + Deploy" does

1 participant