Skip to content

cluster.addWorker returns Dokploy container overlay IP instead of Swarm manager advertise address #4504

Closed

Description

@LJAYi

To Reproduce

Describe the bug

The cluster.addWorker API returns a Docker Swarm join command using the Dokploy container's overlay network IP instead of the actual Docker Swarm manager advertise address.

In my environment, the Swarm manager is correctly advertised as 10.0.0.2, and the Dokploy service has ADVERTISE_ADDR=10.0.0.2. However, the Dokploy UI/API returns a worker join command using 10.0.1.12:2377.

10.0.1.12 is not the host's private IP. It is the Dokploy container IP inside the Swarm overlay network.

Environment

  • Dokploy version: v0.29.5
  • Docker Engine version: 28.5.0
  • OS: Ubuntu 24.04.4 LTS
  • Architecture: aarch64
  • Cloud provider: Oracle Cloud Infrastructure
  • Swarm manager host private IP: 10.0.0.2
  • Dokploy is running as a Swarm service on dokploy-network

Suggested fix

cluster.addWorker should prefer the actual Swarm manager advertise address. Possible approaches:

  1. Use the output from:

bash docker swarm join-token worker

  1. Or read the manager address from Docker info:

text Manager Addresses: 10.0.0.2:2377

  1. Or explicitly respect ADVERTISE_ADDR when generating the join command.

It should not use the Dokploy container's overlay network IP, because that IP is only valid inside the overlay network and cannot be used by external worker nodes to join the Swarm.

Workaround

Manually replace the IP in the command generated by Dokploy:

bash docker swarm join --token 10.0.0.2:2377

instead of:

bash docker swarm join --token 10.0.1.12:2377

Current vs. Expected behavior

Expected behavior

The Add Worker command should use the Docker Swarm manager address:

bash docker swarm join --token 10.0.0.2:2377

This is also what Docker itself returns from:

bash docker swarm join-token worker

Actual behavior

Dokploy returns:

bash docker swarm join --token 10.0.1.12:2377

But 10.0.1.12 is the Dokploy container's overlay network IP, so other nodes cannot use it to join the Swarm cluster.

The API response from:

text /api/trpc/cluster.addWorker?batch=1&input=...

returns:

json [ { "result": { "data": { "json": { "command": "docker swarm join --token 10.0.1.12:2377", "version": "28.5.0" } } } } ]

Provide environment information

## Evidence

Docker Swarm reports the correct manager address:

bash sudo docker swarm join-token worker 

Output:

text docker swarm join --token <token> 10.0.0.2:2377 

bash sudo docker info | grep -A 40 Swarm 

Output:

text Swarm: active Is Manager: true Node Address: 10.0.0.2 Manager Addresses:  10.0.0.2:2377 

The host only has 10.0.0.2 as its OCI private IP:

bash ip addr | grep -E '10\.0\.0\.2|10\.0\.1\.12' 

Output:

text inet 10.0.0.2/24 metric 100 brd 10.0.0.255 scope global dynamic enp0s6 

Dokploy service environment also has the correct advertise address:

bash sudo docker service inspect dokploy --format '{{range .Spec.TaskTemplate.ContainerSpec.Env}}{{println .}}{{end}}' | sort 

Output:

text ADVERTISE_ADDR=10.0.0.2 BETTER_AUTH_SECRET_FILE=/run/secrets/dokploy_auth_secret POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password RELEASE_TAG=latest TZ=Asia/Hong_Kong 

But inside the Dokploy container:

bash sudo docker exec -it <dokploy-container-id> sh -lc 'hostname -I' 

Output:

text 10.0.1.12 172.18.0.4 

And the container route shows:

text 10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.12 172.18.0.0/16 dev eth1 proto kernel scope link src 172.18.0.4 

This strongly suggests that cluster.addWorker is using the Dokploy container's internal IP, possibly from hostname -I or a similar runtime IP detection method, instead of using either:

1. docker swarm join-token worker
2. Docker's Manager Addresses
3. the ADVERTISE_ADDR environment variable

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?

Same server where Dokploy is installed

Additional context

No response

Will you send a PR to fix it?

No

Activity

  1. dosubot commented on May 28, 2026

    @dosubot

    Hi @LJAYi! I'm Dosu and I’m helping the dokploy team.

    I can confirm the root cause. The cluster.addWorker implementation calls getLocalServerIp() when no serverId is provided [1], and that function runs ip addr show | grep ... inside the Dokploy container [2]. Since Dokploy runs as a Swarm service on an overlay network, the first private IP it finds is the container's overlay IP (10.0.1.12) rather than the host's actual IP (10.0.0.2).

    The fix should be straightforward — instead of detecting the IP via ip addr show inside the container, the code should either:

    1. Use the Swarm inspect result that's already available in that function — docker.swarmInspect() returns manager addresses.
    2. Read process.env.ADVERTISE_ADDR which is already set correctly in the Dokploy service spec.
    3. Shell out to docker swarm join-token worker on the host (via the Docker socket) and parse the address from its output.

    Option 2 is probably the simplest since ADVERTISE_ADDR is already injected into the container environment and represents the intended manager address. The relevant code is in apps/dokploy/server/api/routers/cluster.ts around line 100.

    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. Siumauricio commented on Jun 7, 2026

    @Siumauricio
    Contributor

    Close here #4567

  3. added
    duplicateThis issue or pull request already exists
    and removed on Jun 7, 2026
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 workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions