Skip to content

Wrong IP address in docker swarm join command generated in "Add Node" #4517

Closed

Description

@rem-aster

To Reproduce

To Reproduce

  1. Set up self-hosted Dokploy. Docker Swarm will be initialized (the swarm will use the correct advertise address, e.g., 10.174.87.3).
  2. In the Dokploy UI, navigate to the cluster section and open the Add Node dialog.
  3. Copy the docker swarm join command shown in the UI.
  4. Compare it with the output of docker swarm join-token worker run directly on the server.

Result:

UI command: docker swarm join --token 10.0.1.8:2377
Swarm command: docker swarm join --token 10.174.87.3:2377

Note: i also checked dokploy container env, ADVERTISE_ADDR is correct there

Current vs. Expected behavior

Current behavior:
The UI generates the docker swarm join command using an IP address determined by getLocalServerIp() (for the local server) or server.ipAddress from the database (for a remote server). getLocalServerIp() runs ip addr show and returns the first private IP address found on any network interface, which may not match the actual Docker Swarm advertise address. This produces an incorrect join command that will fail when the worker tries to connect to the manager.
Expected behavior:
The UI should generate the docker swarm join command using the IP address that Docker Swarm itself is already advertising. This information is available from docker.swarmInspect() (already called in the same addWorker/addManager procedure in cluster.ts). The IP should be taken from the swarm inspect result (e.g., RemoteAddr or ListenAddr) instead of being independently re-determined by a separate method.
Affected code:
apps/dokploy/server/api/routers/cluster.ts, procedures addWorker and addManager (lines ~80–141).

Provide environment information

Dokploy version: v0.29.5
Ubuntu 22

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

Local Development, Installation

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. dosubot commented on May 30, 2026

    @dosubot

    This is a duplicate of #4504 [1]. The root cause is confirmed: getLocalServerIp() runs ip addr show inside the Dokploy container, so it picks up the overlay network IP (e.g., 10.0.1.x) rather than the host's actual Swarm advertise address.

    The fix should replace the IP detection in apps/dokploy/server/api/routers/cluster.ts (~line 100) with one of:

    1. process.env.ADVERTISE_ADDR — already set correctly in the Dokploy service spec (simplest option).
    2. docker.swarmInspect() — already called in the same procedure; manager addresses are available in the result.
    3. Parse output of docker swarm join-token worker via the Docker socket.

    Workaround for now: manually replace the IP in the generated command with the correct one (visible via docker swarm join-token worker on the host).

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dokploy with Dosu Add Dosu to your team

  2. rem-aster commented on May 30, 2026

    @rem-aster
    Author

    @dosu what is the current status of this bug? Should i submit a PR?

  3. dosubot commented on May 30, 2026

    @dosubot

    @rem-aster This bug appears to still be present. A previous PR (#2650) attempted a fix by updating getLocalServerIp(), but the current implementation still runs ip addr show inside the Dokploy container [1] — which is exactly the problem you're hitting. It grabs the first private IP from any interface, which inside the container ends up being the overlay network IP rather than the host's actual swarm advertise address.

    Your issue is a duplicate of #4504, which reported the same root cause and symptoms.

    A PR would definitely be welcome! The cleanest fix would likely be to use process.env.ADVERTISE_ADDR (already available in the container) as the preferred source for the IP in the addWorker/addManager procedures in cluster.ts, falling back to the current detection only if that env var isn't set. Alternatively, extracting the manager address from the docker.swarmInspect() result (which is already called in those procedures) would also work reliably.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about dokploy with Dosu Add Dosu to your team

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions