Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

How to read the IP addresses of swarm tasks? #1140

Copy link
Copy link

Description

@kamalhakim
Issue body actions

Hi,

Is there any way to read the ip address of swarm tasks?

I make a docker client poniting to the leader of the swarm via:

   DockerClientConfig config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost("unix:///var/run/docker.sock").build();
   DockerClient client = DockerClientBuilder.getInstance(config).build();

I read the tasks of a service by:

    List<Task> tasks = client.listTasksCmd().withServiceFilter(serviceName).exec();

Then I tried the following two ways to find the ip address of a task:

  1. fetching continer by id:
   TaskStatus status = task.getStatus();
   TaskStatusContainerStatus containerStatus = status.getContainerStatus();
   String containerID = containerStatus.getContainerID();
   List<String> idfilter = new ArrayList<>();
   idfilter.add(id);
   List<Container> list = client.listContainersCmd().withShowAll(true).withIdFilter(idfilter).exec();
  1. fetching container from overlay network:
   List<Network> netList = client().listNetworksCmd().withNameFilter(new String[]{netName}).exec();
   Network network = netList.get(0);
   Map<String, Network.ContainerNetworkConfig> containers = network.getContainers();

But both return an empty list - or they do not return the containers that are placed on other swarm nodes.

Is this feature supported in the API?

Thanks!

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.